Find and replace string in a word document

Just starting out? Need help? Post your questions and find answers here.
ClueLess
Enthusiast
Enthusiast
Posts: 345
Joined: Sun Jan 11, 2009 1:04 am

Find and replace string in a word document

Post by ClueLess »

I need to find a string in a word document and replace it. No idea how I can do it. Any help please?
wayne-c
Enthusiast
Enthusiast
Posts: 335
Joined: Tue Jun 08, 2004 10:29 am
Location: Zurich, Switzerland

Re: Find and replace string in a word document

Post by wayne-c »

.doc (binary) or .docx (XML)? If it's docx, unpack, open xml, find and replace. if it's binary, find a library to to it?
As you walk on by, Will you call my name? Or will you walk away?
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Find and replace string in a word document

Post by skywalk »

The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
ClueLess
Enthusiast
Enthusiast
Posts: 345
Joined: Sun Jan 11, 2009 1:04 am

Re: Find and replace string in a word document

Post by ClueLess »

@ wayne-c
I know it is binary

@ skywalk

I tried to, but gave me an error on Comate
ClueLess
Enthusiast
Enthusiast
Posts: 345
Joined: Sun Jan 11, 2009 1:04 am

Re: Find and replace string in a word document

Post by ClueLess »

@ wayne-c

How do I unpack the docx document?
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: Find and replace string in a word document

Post by RSBasic »

@ClueLess
doxc is a ZIP archive:

Code: Select all

UseZipPacker()

If OpenPack(0, "C:\...\YourDocument.docx") 
  If ExaminePack(0)
    While NextPackEntry(0)
      Debug "Name: " + PackEntryName(0) + ", Size: " + PackEntrySize(0)
      ;UncompressPackFile()
    Wend
  EndIf
  
  ClosePack(0)
EndIf
Image
Image
Post Reply