I am using Word 2003.
I have created a macro that gets the filename beginning with the
server/sharename, using the ShareName Property.
It stores it in a document variable. I can then put it in the document,
eg., the footer. (The built-in filename path returns the mapped drive, eg. I:
We want \\ServerName\ShareName )
I have put this macro in the template for these files. I also put a
document_open event macro in ThisDocument of the template.
That is working fine. So I am set up for the existing documents.
But I am having a problem with new documents, or those created with SaveAs.
The filename does not exist until after the new file is saved. For SaveAs,
the filename before the save is the old one.
What is the best way to handle this? If there were an AfterSave event, it
would make things much easier.
Do I have to create my own macros for FileClose, Filesave, FileSaveAs, and
FileSaveAll, and do all that file dialog stuff?
I believe (hope) I can put these in the template, also.
Looking at the Help for "Using Events with the Application Object", I see I
have to Initialize the Declared Object.
It looks as if I can run this one time, and it make the required connections
so things will work when I create, open, and close documents. Or do I
misunderstand this.
Jean-Guy Marcil - 12 Sep 2006 03:53 GMT
Patricia Shannon was telling us:
Patricia Shannon nous racontait que :
> I am using Word 2003.
> I have created a macro that gets the filename beginning with the
[quoted text clipped - 23 lines]
> connections so things will work when I create, open, and close
> documents. Or do I misunderstand this.
All you need to highjack are FileSave and FileSaveAs.
With FileSave, just check if the ActiveDocument has a Path, if it doesn't,
call FileSaveAs, something like:
'_______________________________________
Sub FileSave()
If ActiveDocument.Path = "" Then
FileSaveAs
Else
ActiveDocument.Save
End If
End Sub
'_______________________________________
'_______________________________________
Sub FileSaveAs()
Dialogs(wdDialogFileSaveAs).Show
'Your Code to create the doc variable
ActiveDocument.Save
End Sub
'_______________________________________

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
Patricia Shannon - 12 Sep 2006 14:20 GMT
Thank you very much. That's not as bad as I thought.
> Patricia Shannon was telling us:
> Patricia Shannon nous racontait que :
[quoted text clipped - 55 lines]
> End Sub
> '_______________________________________
Patricia Shannon - 22 Sep 2006 14:43 GMT
Thanks muchly. It works like a charm. For the benefit of other people who
might see this and are at my level of VBA experience, I was able to put it in
a normal VBA module in the template, not in ThisDocument. I didn't need the
event macro stuff.
> Patricia Shannon was telling us:
> Patricia Shannon nous racontait que :
[quoted text clipped - 55 lines]
> End Sub
> '_______________________________________