PDA

View Full Version : Solved: Saving Word Docs To a Specific Directory With Automation



sandam
02-10-2005, 03:36 AM
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;?

Jacob Hilderbrand
02-10-2005, 04:24 AM
Just specify the path when you save.

ActiveDocument.SaveAs Filename:=MyPath & "\" & MyFileName & ".doc"

sandam
02-10-2005, 05:34 AM
Thanks again for you help :):beerchug: .

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.

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

Jacob Hilderbrand
02-10-2005, 05:54 AM
Glad to help. :beerchug:

Take Care