Results 1 to 3 of 3

Thread: Writing to documents without opening them

  1. #1
    jfc1hss is offline C# Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Dec 2016
    Posts
    2
    Rep Power
    0

    Writing to documents without opening them

    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.

  2. #2
    JuggaloBrotha's Avatar
    JuggaloBrotha is offline C# Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Apr 2011
    Location
    Lansing, MI; USA
    Posts
    85
    Rep Power
    76
    Quote Originally Posted by jfc1hss View Post
    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.

  3. #3
    jfc1hss is offline C# Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Dec 2016
    Posts
    2
    Rep Power
    0
    Quote Originally Posted by JuggaloBrotha View Post
    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?

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •