Consulting

Results 1 to 6 of 6

Thread: Solved: saving a file to a particular drive

  1. #1
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location

    Solved: saving a file to a particular drive

    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.
    Peace of mind is found in some of the strangest places.

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You need to make a Class Module to get the Before Save Event in Word. I outlined an example in This Thread. Take a look and see if that helps you or not.

  3. #3
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    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?
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  4. #4
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    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.
    Peace of mind is found in some of the strangest places.

  5. #5
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    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 ..

    [VBA]Sub FileSave()
    ActiveDocument.SaveAs "report" & Format(DateAdd("d", 1, Date), "mmddyyyy")
    End Sub[/VBA]
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  6. #6
    Administrator
    VP-Knowledge Base VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi,

    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: [VBA]Sub FileSaveAs()
    ActiveDocument.SaveAs "report" & Format(DateAdd("d", 1, Date), "mmddyyyy")
    End Sub

    [/VBA]
    Enjoy!
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •