Why am I receiving "Reference to non-existent field 'Execute'" error?

2 views (last 30 days)
I'm currently working on a project where I compose a report in a word document using activex! I'm stuck on a block of code meant to search the active document for a certain phrase and replace it with another (referencing this post). Below is the section of code I am struggling with:
w.Selection.Find.Font.Size = 10; % identify features of text to search for
w.Selection.Find.Font.Name = 'Arial';
fail = '!FAIL!'
color = text_color(fail, version, 6) % color fail message red
search = sprintf('PASS - See Section %s', section)
replace = sprintf('%s - See Section %s', section)
selection = w.Selection
selection.Find.Execute(search,1,0,0,0,0,1,0,1,replace,2,0,0,0,0) % actual search/replace function
I keep encountering an error during the actual Selection.Find.Execute method that says "Reference to non-existent field 'Execute'. I can't seem to figure out what is causing this problem, or what the defining difference is between my code and the one in the example. I know that in the example, they open and establish the active document in the snippet itself, but I don't believe that is the problem
I'm very new to MATLAB and only have experience with Python, so this is all very new to me. Thank you for being patient!

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by