PDA

View Full Version : Solved: saving a file to a particular drive



austenr
04-08-2005, 02:17 PM
I know how to do this in EXCEL but not sure how to do it in Word. Automatically save to a specific drive without a user prompt. Thanks to anyone that can help. :dunno

Jacob Hilderbrand
04-08-2005, 02:26 PM
You need to make a Class Module to get the Before Save Event in Word. I outlined an example in This Thread (http://www.vbaexpress.com/forum/showthread.php?t=2575). Take a look and see if that helps you or not.

TonyJollans
04-09-2005, 12:09 AM
You can probably do it more simply than that by intercepting the Word commands, but can you give a bit more detail about what you mean by automatically? Automatically when? Do you want to override normal saving, or automatically save on exit, or something else?

austenr
04-09-2005, 07:42 AM
Just want to somehow save the file so the user has to do nothing except click save. I want the path to be defined internally. Each day the file will be saved to a folder where it will be archived. I need to find a way to have it saved for example report01012005, report01022005 etc. I would like to have it save it by adding 1 to the day and 1 to the month if that month is ended.

TonyJollans
04-09-2005, 09:20 AM
If you create a routine called FileSave (in a standard module in the document or its template - it might depend a bit how the document is being created) it will be run instead of the built in Save command and you can do what you want in the routine, for example ..

Sub FileSave()
ActiveDocument.SaveAs "report" & Format(DateAdd("d", 1, Date), "mmddyyyy")
End Sub

MOS MASTER
04-09-2005, 11:13 AM
Hi, :D

Intercepting Word Commands is the way to go.
Tony's Sub runs when a user presses the "Save" button..however a lot off people do use the "SaveAs" button in the "File" menu so add this procedure as well: Sub FileSaveAs()
ActiveDocument.SaveAs "report" & Format(DateAdd("d", 1, Date), "mmddyyyy")
End Sub


Enjoy! :thumb