Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2007

Tip: Looking for answers? Try searching our database.

Put File Name Of A Document On Line 1 Of The Document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mikeburg - 14 Dec 2007 15:10 GMT
I am needing auto open VBA code that will center the name "FAX MESSAGE COVER
PAGE", the document's file name (always different) & today's date all on line
1 when it's opened (I already have auto open VBA that save the document, with
Save As, the user's name in the file name).
For example, when I open the document MW070.doc, it's auto open VBA has
saved as MW070mike.doc. What I need is the following centered on the 1st line:
FAX MESSAGE COVER PAGE MW070mike.doc 12-14-07
Keep in mind, the MW070mike.doc, will be MW070sherry.doc if user sherry
opens MW070.doc, etc. So the VBA needs to use the new file name in the Line 1
line.
Thanks so very much for all your help. mikeburg
Graham Mayor - 15 Dec 2007 10:18 GMT
Why not simply put a filename field in the document/template. There is no
need for vba to do so.
e.g.
FAX MESSAGE COVER PAGE {Filename} {Date \@ "MM-dd-yy"}

or

Dim fName As String
With ActiveDocument
   .Save
   fName = .Name
   With Selection
       .ParagraphFormat.Alignment = wdAlignParagraphCenter
       .TypeText "FAX MESSAGE COVER PAGE " & _
           fName & Format(Date, " MM-dd-yy")
       .TypeParagraph
       .ParagraphFormat.Alignment = wdAlignParagraphLeft
   End With
End With

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> I am needing auto open VBA code that will center the name "FAX
> MESSAGE COVER PAGE", the document's file name (always different) &
[quoted text clipped - 10 lines]
> the Line 1 line.
> Thanks so very much for all your help. mikeburg
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.