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 / May 2008

Tip: Looking for answers? Try searching our database.

Invoke, and pass argument to, File Save As dialog, with a macro?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob W - 13 May 2008 18:21 GMT
For a specific template only, can a macro trigger a file/save as AND place a
suggested file naming convention prompt in the Filename window of the File
'Save As' dialog?

ie,
User clicks a macrobutton;
Word's Save As dialog opens;
In the File Name window, a suggested file name schema appears, ie.,
"please type the date (yymmdd), check number, and brief description of item"
Jay Freedman - 13 May 2008 18:38 GMT
> For a specific template only, can a macro trigger a file/save as AND
> place a suggested file naming convention prompt in the Filename
[quoted text clipped - 6 lines]
> "please type the date (yymmdd), check number, and brief description
> of item"

I wouldn't advise doing it that way. Guaranteed, at some point you'll hit
Enter unintentionally and get a file named "please type the date (yymmdd),
check number, and brief description of item.doc".

A better idea is to intercept the Save As command
(http://www.word.mvps.org/FAQs/MacrosVBA/InterceptSavePrint.htm), display an
inputbox or userform to get the necessary information (or, preferably,
construct the filename from information already in the document), and place
the suggested filename into the Title document property
(http://www.word.mvps.org/FAQs/MacrosVBA/SetDefFilename.htm). Then call
Dialogs(wdDialogFileSaveAs).Show
(http://www.word.mvps.org/FAQs/MacrosVBA/WordDlgHelp.htm).

If the FileSaveAs macro is stored in the same template used as a base for
this type of document, then it will operate only in those documents.

Signature

Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

Bob W - 13 May 2008 23:18 GMT
Simply running Sub AutoNew() causes the file save as dialog to appear.
The suggested file name (suggested by Word) is always the Title in Document
Properties (which Word somehow automatically extracts from the first sentence
in the document).  I'd settle for a simple way to insert a desired file
naming convention prompt in the DocProperties Title box in place of the text
that Word automatically places there. I'm not seeing how to do that,
however....learning Word Basic on the fly is agonizingly slow sometimes.

I am not too concerned about people accidentally generating files named,
"please type the date (yymmdd), check number, and brief description of
item.doc"...I almost like it that way: it provides immediate albeit slightly
annoying reinforcement of the naming convention.

> > For a specific template only, can a macro trigger a file/save as AND
> > place a suggested file naming convention prompt in the Filename
[quoted text clipped - 22 lines]
> If the FileSaveAs macro is stored in the same template used as a base for
> this type of document, then it will operate only in those documents.
Bob W - 14 May 2008 00:17 GMT
Correction: putting the following subroutine in a template causes the file
save dialog to appear whenever one creates a new .doc from a template:

Sub AutoNew()
Dialogs(wdDialogFileSaveAs).Show
End Sub

..then in the template, if you insert your desired filename convention
prompt in Document Properties - File Name, such as 'yymmdd check number item
description' and save the template, when you use the template to start a .doc
it will automatically force the user to save the new .doc immediately and
your prompt will appear in the file name field to (hopefully) remind people
of your naming convention.

That's one very quick and dirty way to do it.  One caveat I observed: your
prompt can't contain anything but letters and numbers.

Jay, your solution sounds far more professional and desirable, but, alas,
complicated beyond my capabilities, at least for now. But many thanks - those
MVP links  got me this far, and hopefully not into too much trouble ...

> Simply running Sub AutoNew() causes the file save as dialog to appear.
> The suggested file name (suggested by Word) is always the Title in Document
[quoted text clipped - 35 lines]
> > If the FileSaveAs macro is stored in the same template used as a base for
> > this type of document, then it will operate only in those documents.

Rate this thread:






 
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.