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 2006

Tip: Looking for answers? Try searching our database.

specfic file name macro from form fields entries

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TBolt - 03 Dec 2006 13:54 GMT
I want a document to automatically have the file name entered when an
employee clicks save or the save as. The file name will be a combination of
two form fields (Text6 and Text70). Is there a way to get the entries from
these two fields and append them into one file name?

I also would like to these save at a specific location on a network drive.

I have no experience in VB.

Word 2003

Any help would be appreciated!
Cindy M. - 05 Dec 2006 18:28 GMT
Hi TBolt,

> I want a document to automatically have the file name entered when an
> employee clicks save or the save as. The file name will be a combination of
[quoted text clipped - 6 lines]
>  
> Word 2003

You could try something along these lines. The "FileSave" and "FileSaveAs"
subs intercept the built-in commands of the same name so that when the user
clicks those buttons or uses the keyboard shortcuts your code is executed.

You'll find instructions on mvps.word.org on how to use macros people give
you in the newsgroups. You want to insert a new module in the form template
(or document, you don't specify) and copy the code to that. Substitute the
file path you want to use in the CustomSave procedure.

Sub FileSave()
   CustomSave
End Sub

Sub FileSaveAs()
   CustomSave
End Sub

Sub CustomSave()
   Dim fileName as String
   fileName = "C:\pathInfo\"
   fileName = fileName & _
     ActiveDocument.Formfields("Text6").Result & _
     ActiveDocument.Formfields("Text70").Result & _
     ".doc"

   ActiveDocument.SaveAs fileName
End Sub

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)
 
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.