Results 1 to 4 of 4

Thread: Solved: Word Automation

  1. #1
    VBAX Regular
    Joined
    Apr 2005
    Posts
    27
    Location

    Solved: Word Automation

    Hello

    I am connecting to words automation server from a third party application to achieve the following:

    A saved word file/template opens, the user makes the desired edits and saves the document, which then locks and saves as a var name (var x.doc, for examples sake). The original file/template remains unchanged and unlocked, ready to be opened by the next session.

    I have achieved this by the following process:

    1) Original.doc is opened
    2) User makes changes and instructs save
    3) Third party app intervenes ondocumentbeforesave and cancels save
    4) Third party app does SaveAs x.doc // to change name before locking so Original.doc is left intact
    5) TP app does Protect(wdAllowOnlyFormFields, True)
    6) TP app does Save

    As you can see, I am having to save twice to achieved the desired affect. Is there any way around this? Any further suggestions/comments about my entire approach to this task would be much appreciated as my Word knowledge is very lacking.

    Thanking you in advance.

    Levksi

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi,

    Welcome to VBAX!

    It's hard for me to imagion what this third party app is doing to you're documents..

    But you're question seams to be: "Can I improve my code?"

    If so..please post you're code so people can respond on possible improvemts in code execution?

    Enjoy!
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  3. #3
    VBAX Regular
    Joined
    Apr 2005
    Posts
    27
    Location
    The code itself is not a problem in that it works perfectly for the process described above.

    What I am wondering is if there is any way in VBA that I can change a name of a document without doing a SaveAs (which would save me what seems to be a superfluous save).

    Also not sure if the original document should be a .doc or a .dot. It will pretty much be a finished document into which docvariables are sent. I want the original to remain unchanged when closed, the changes instead being reflected in the x.doc doc that the SaveAs creates. Any advice about this would be welcome.

    (The third party app, incidentally, is just a delphi project that connects to Word's automation server and passes variables between itself and Word).

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi,

    You should use a *.dot (Template) file for you're base on witch you can make *doc (Document) files based on the *dot File.

    To be short use the *dot as base...

    Can you be more specific about renaming this document while not open?

    Is it a FreeFile? (Not in Use)

    Enjoy!
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

Posting Permissions

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