How to find and replace text provided in a textbox in a .docx file?

11 visualizaciones (últimos 30 días)
iitm_pnkj
iitm_pnkj el 17 de Ag. de 2021
Comentada: iitm_pnkj el 17 de Ag. de 2021
I have a word file in which some text is written in a text box. How can I change the text provided in the text box?
  1 comentario
iitm_pnkj
iitm_pnkj el 17 de Ag. de 2021
Finally I have solved.
wordFile = 'C:\Users\doc1.docx';
word = actxserver('Word.Application');
wdoc = word.Documents.Open(wordFile);
%wdoc is the Document object which you can query and navigate.
TextBox = wdoc.Shapes.Item(1)
Text = TextBox.TextFrame.TextRange.Find.Execute('text1',0,0,0,0,0,1,1,0,'replacetext',2,0,0,0,0);
%Text = sometext.TextFrame.Characters.Text;
wdoc.Close; % close document
word.Quit; % end application

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by