R
Reiner Griess
Hi there,
hopefully you guys guide me... Im not familiar with VB.
I want to add the filename of a special format in the footer of a word
doc, automatically everytime I save the doc.
This is what I want in detail:
1. When file gets saved
- set file name (document property) to the name of the file, trimmed
down to the characters before the first underscore (_).
E.g. Filename is "myfile_sometxt.doc" -> will get "myfile"
2. Automatically set the filename variable (trimmed down in step 1) into
the footer of the document.
Any help would be reaaaally appreciated.
Tank you!
reiner
PS: This is what I've done so far...
Macro to get the trimmed down filename:
Sub InsertFnameOnly()
Dim fname, fname2 As String
ActiveDocument.Save
fname2 = Selection.Document.Name
fname = Left(fname2, (InStr(fname2, "_") - 1))
Selection.TypeText fname
End Sub
Problems:
- how to set the filename in document properties?
- how to paste the trimmed filename into the footer?
- how to do this automatically (ie without the need of explicitely
execute any macro)?
hopefully you guys guide me... Im not familiar with VB.
I want to add the filename of a special format in the footer of a word
doc, automatically everytime I save the doc.
This is what I want in detail:
1. When file gets saved
- set file name (document property) to the name of the file, trimmed
down to the characters before the first underscore (_).
E.g. Filename is "myfile_sometxt.doc" -> will get "myfile"
2. Automatically set the filename variable (trimmed down in step 1) into
the footer of the document.
Any help would be reaaaally appreciated.
Tank you!
reiner
PS: This is what I've done so far...
Macro to get the trimmed down filename:
Sub InsertFnameOnly()
Dim fname, fname2 As String
ActiveDocument.Save
fname2 = Selection.Document.Name
fname = Left(fname2, (InStr(fname2, "_") - 1))
Selection.TypeText fname
End Sub
Problems:
- how to set the filename in document properties?
- how to paste the trimmed filename into the footer?
- how to do this automatically (ie without the need of explicitely
execute any macro)?