Consulting

Results 1 to 4 of 4

Thread: Solved: Saving Word Docs To a Specific Directory With Automation

  1. #1
    Knowledge Base Approver
    Space Cadet
    VBAX Tutor sandam's Avatar
    Joined
    Jan 2005
    Location
    London
    Posts
    292
    Location

    Solved: Saving Word Docs To a Specific Directory With Automation

    Hi there, this be my mofo problem.

    I have a vendors product that creates a document from a template(header "Header.dot") and another document(word doc - "TheLetter.doc"). These merge fields so they are first combined and then merged to create a new document ("Form Letter x.doc").

    I then run macros on the created document using an attached template situated on a network drive along with the vendors product. I am trying to get the document to save to a specific directory (using a macro of course ) with only a description input by the user (i want to set the directory according to client references) but even if I use 'ChDir myDirectory' and then 'ActiveDocument.SaveAs Filename:= myFileName' I cant get it to save to the specified directory.

    It continues to save to the My Documents Folder which is specifed as the standard save folder in the options dialog and I can't change that either (i tried ). I need some help please.

    Thanks In Advance
    Andrew;?

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Just specify the path when you save.
    [vba]
    ActiveDocument.SaveAs Filename:=MyPath & "\" & MyFileName & ".doc"
    [/vba]

  3. #3
    Knowledge Base Approver
    Space Cadet VBAX Tutor sandam's Avatar
    Joined
    Jan 2005
    Location
    London
    Posts
    292
    Location
    Thanks again for you help .

    This is what it looks like so far - now all i have to do is some IF logic in the rest of the template to check if files have been saved.

    [VBA] Sub SaveTheDoc(sFileSaved As Boolean, Optional sChangename As Boolean = False)
    Dim DocDescrip As String
    If Not sFileSaved Or sChangename Then
    DocDescrip = InputBox("Please enter a description of the document save as", "SAVING DOCUMENT")
    While Len(DocDescrip) = 0
    DocDescrip = InputBox("Please enter a description of the document save as", "SAVING DOCUMENT")
    Wend
    DocDescrip = docsPath + getDirectory(selectDirectory) + DocDescrip + ".doc"
    ActiveDocument.SaveAs FileName:=DocDescrip
    ActiveDocument.AttachedTemplate.Saved = True
    Else
    ActiveDocument.Save
    End If
    MsgBox ActiveDocument.path
    End Sub [/VBA]

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Glad to help.

    Take Care

Posting Permissions

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