Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro saving Word document to wrong location 1

Status
Not open for further replies.

thefear

Technical User
Mar 24, 2004
20
Hi,

I'm updating a raft of policy documents with new logos, etc. I've got one word document(Template) open with the new items, and I open each policy document in turn to read and paste into as necessary.

I've written a macro that will save the file I'm working on with a new filename if hasn't done so already. If it has, it keeps the new filename.

If Right(ActiveDocument.Name, 7) = "mft.doc" Then
newname = ActiveDocument.Name
Else
newname = Left(ActiveDocument.Name, Len(ActiveDocument.Name) - 4) & " mft.doc"
End If
ActiveDocument.SaveAs FileName:=newname, FileFormat:= _
wdFormatDocument

End Sub

This macro is saved in the Template I've always got open, and I've created a button that runs the macro that appears in all the documents I have open .

The problem is it saves the new file to the Template's location rather than the location of the policy document that I actually triggered the macro from. It saves the right file, under the right name to the wrong location.

I've tried to find a property of the ActiveDocument that describes file path, but not found one. Can anyone give me a tip?

Thanks
 
ActiveDocument.SaveAs FileName:=ActiveDocument.Path & Application.PathSeparator & newname

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top