Consulting

Results 1 to 3 of 3

Thread: How do I Save to shared folder with original file name using macros?

  1. #1
    VBAX Newbie
    Joined
    Jun 2012
    Posts
    1
    Location

    Exclamation How do I Save to shared folder with original file name using macros?

    I have recorded a macro to save my files to a shared folder on my computer. Only issue being that when I use this on a new document it saves with the same file name and overwrites the document already saved. I want it to save the file with the original file name rather than the one used when recording the macro.
    ChangeFileOpenDirectory "O:\Team NF CV's\"
    ActiveDocument.SaveAs2 FileName:="O:\Team NF CV's\Jaumns.docx", FileFormat _
    :=wdFormatXMLDocument, LockComments:=False, Password:="", _
    AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
    EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
    :=False, SaveAsAOCELetter:=False, CompatibilityMode:=14
    End Sub
    It is the second line down where it uses the filename Jaumns.docx rather than the original unique file name.
    Any help appreciated.
    Last edited by klucas87; 06-25-2012 at 06:38 AM. Reason: Not getting desired response

  2. #2
    VBAX Expert Tinbendr's Avatar
    Joined
    Jun 2005
    Location
    North Central Mississippi (The Pines)
    Posts
    993
    Location
    MSDN specifically states that file will be overwritten.

    You'll have to test it's existence before hand.

    [vba]FileExists = (Dir(FileName) > "")'Returns True/False[/vba]

    David


  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    Not sure what it is you're really looking to do

    To save a doc opened from one folder back to your shared folder, I'd do something like this

    [VBA]

    Sub SaveIt()
    ActiveDocument.SaveAs FileName:="O:\Team NF CV's\" & ActiveDocument.Name
    End Sub
    [/VBA]

    Paul

Posting Permissions

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