PDA

View Full Version : Solved: Word Automation



Levski
04-19-2005, 08:18 AM
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

MOS MASTER
04-19-2005, 11:52 AM
Hi, :D

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! :thumb

Levski
04-19-2005, 01:32 PM
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).

MOS MASTER
04-19-2005, 01:36 PM
Hi, :D

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...:rofl:

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

Is it a FreeFile? (Not in Use)

Enjoy! :thumb