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

1 visualización (últimos 30 días)
Adrienne Vescio
Adrienne Vescio el 29 de Sept. de 2022
Comentada: Cel Kulasekaran el 29 de Sept. de 2022
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!
  2 comentarios
Mario Malic
Mario Malic el 29 de Sept. de 2022
Did you select anything in the document?
Cel Kulasekaran
Cel Kulasekaran el 29 de Sept. de 2022
This is a matter of ActiveX syntax and object organization, you can start the activex com interaction and go line by line, guided with VBA / ActiveX documentation.

Iniciar sesión para comentar.

Respuestas (0)

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by