Question Writing to documents without opening them

jfc1hss

New member
Joined
Dec 13, 2016
Messages
2
Programming Experience
Beginner
Hi,

I know that I can write to open documents using the "Application.ActiveDocument" attribute.

Is there a way to edit a document without opening them?

I need to edit thousands of documents, and I'd like to write a script for this. If I need to open each document one at a time, it kind of defeats the object.
 
Hi,

I know that I can write to open documents using the "Application.ActiveDocument" attribute.

Is there a way to edit a document without opening them?

I need to edit thousands of documents, and I'd like to write a script for this. If I need to open each document one at a time, it kind of defeats the object.
What are you needing to edit in these documents?
If it's a matter of adding something to the beginning and/or to the end then it might be really straight forward to accomplish this, but if you need to add or change something in the middle then you'll need to do some parsing, either way you'll need to read in the current contents of the file so you can write them out again with the changes, probably all of which will be able to be done far faster by a program than to open them individually yourself.
 
What are you needing to edit in these documents?
If it's a matter of adding something to the beginning and/or to the end then it might be really straight forward to accomplish this, but if you need to add or change something in the middle then you'll need to do some parsing, either way you'll need to read in the current contents of the file so you can write them out again with the changes, probably all of which will be able to be done far faster by a program than to open them individually yourself.

Thanks,

I need to edit a particular block within a file. It's the same change over and over. I can change the block when the document is open using the method I described. I have a fully working programme for this. I'm trying to find out how I can adapt my script to write to many files at once. I have an idea which should work by opening and closing each file. However the best solution would write to the file without opening it.

This can be done with plain text documents, I'm wondering if this can be done with more complex .net applications. Does anybody know?
 
Back
Top Bottom