Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting Save event in Word.

Status
Not open for further replies.

Aristarco

Programmer
Jun 19, 2000
77
0
0
MX
I was asked to develop a routine (read script, macro, etc.) to intercept the <b>Save </b>or <b>Save As</b> box in MS Word 97, so I can display a form that forces the user to name the file to be saved with a uniform, sort-of-standardized file name. Let's say the document is a bibliography, from a department called Genetic Research, and the latest version is 4. The name should be <FONT FACE=monospace>BI_GenRs_04.doc</font> and the main concern in this office is that the users keep naming the files at their will. Does anyone out there knows how can I intercept the event so I can use my very own &quot;Save&quot; box?
 
Each &quot;built in&quot; command can be overridden in Word by creating a macro which will do what you wish, and then name it the same as the original command.&nbsp;&nbsp;(See Tools, Macro, Macros, Macros in:&nbsp;&nbsp;Word Commands)<br><br>First, build a dialog box which forces the user to input a file name exactly as you wish it to be formatted.&nbsp;&nbsp;Add a Save button (later you can add cancel, etc). Name the file SaveDialog2<br><br>Then record the coding for saving a file -- call it SaveTest.&nbsp;&nbsp;Use a dummy file and dummy file name.<br><br>Move this code to the Save button &quot;On Click&quot; event on SaveDialog2.<br><br>Change the &quot;dummy&quot; file names to variables based on the names given to the text box you built in the SaveDialog2 form.<br><br>Also, to test at runtime, put a message box at the top of all code, such as MsgBox &quot;Hi, Aristarco&quot;<br><br>While in edit mode, change the name of the SaveDialog2 macro to FileSave.<br><br>When you click File ¦ Save on the menu, first your custom dialog box should appear.<br>When Save is clicked on your dialog (after putting in the file name), the macro should pick up the variable from the dialog box, place it into the code also behind the Save button, and save the document.<br><br>This is just a start.&nbsp;&nbsp;Some other housekeeping should be done as well, such as clearing the screen, etc.<br><br>Dan<br><br><br>Input File Name:&nbsp;&nbsp;____________<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦Save¦<br><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top