Skip to main content
gamedev.net
🔒 Locked

Modify a winword document ?

Started by DarkEmpire 5 replies 550+ views
Original Post
DarkEmpire
DarkEmpire
Hi, I have a problem, and i didn''t find a solution. Here it is: I want to replace a string in a Winword document with an other one. Ex: i create a new document essai.doc (with Word application), i write blabla and i save. If i use Notepad to open essai.doc, and to replace blabla by blibli, i can not reopen essai.doc with WinWord. So i think that with an executable, the problem will be the same. Is there a tip to solve my problem ?
DocJunioR
DocJunioR
hmm..
try Visual Basic. it''s easy to use...
cYaDjR====================may you be in heaven half an hourbefore devil knows you''re dead ;)
blw
blw
Crazy.

I tried it out, Word really cannot reopen the document.

But I have no clue what the problem is.
640 kByte of memory is all that any application should ever need(Bill Gates 1981)
T2k
T2k
1st you cannot do it with notepad, it will trash the doc, even if you only open it and save it again ...

dont know the filespec, but ive coded an app far ago, which taked one dokument and replaced parts in it with random selected text, and it worked, so you maybe add or remove bytes. This would cause that Word wouldnt open it again.

try to do something like $$xx$$$$$$$$$$$$$ add as many $ as you would need space, then search for the $$ in your file, check xx which mark you have and replace the whole thing with your text and fill the remaining $ with space ... or use the filespec maybe its easier...


T2k
pieman
pieman
IIRC a Word document is stored using the strucutred-storage system look up "IStorage" in the MSDN for info on how to code it). If you have MSVC there''s a util that comes with it called "DocView" which will open a Word file and show you the structure that''s inside it.

HTH

Iain Hutchison
Programmer, Silicon Dreams
The views expressed here are my own, not those of my employer.
Iain HutchisonProgrammer, Silicon DreamsThe views expressed here are my own, not those of my employer.
DarkEmpire
DarkEmpire
Thanks for your help,

I tried with VB and Word.Application... But it is very slow : 5 sec for 3 changes... (windows 2000 and word2000)

Is there a faster solution?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.