PDA

View Full Version : How to work with Word file in Xml with VBA



Dzony
06-22-2016, 12:50 PM
Hi

I have a Word Docx file. I know it's Zip. When I change extension to Zip and unpack it I can reach xml file.

How can I do this via VBA and work with XML content?

I will be grateful for your response

Jan

gmayor
06-22-2016, 10:27 PM
Grab the filename of the document. Make a copy of the file with a zip extension. There are plenty of code examples to extract files from a Zip e.g. http://www.rondebruin.nl/win/s7/win002.htm. Having extracted the files you can then process those that are amenable to VBA processing as you require.

Dzony
07-04-2016, 03:38 AM
I thought there is other more simple way :)
Thank you again gmayor

Frosty
07-09-2016, 07:23 AM
Alternatively, you can explore the .WordOpenXML and .InsertXML property and method off of a range object, if you want to modify the xml directly without having to close and re-open the document.

but this is almost as much a rabbit hole as ronde bruin's method.