how to override save saveAs second time around

L

lik

I have a macro set to auto fill in the file name when a user clicks save or
save/as. Right now multiple open and save/saveas of the documents will
always use my prefilled info I have defined in the macro. If a user
overrides my default and saves the document. The next time they open the
doucment and click on save or save-as, how do I code to use what they named
it rather than my default. Im probably not making myself clear, so here is
an example;

My code for save is
Sub FileSave()
With Dialogs(wddialogfilesaveas)
..Name = "TP" & ActiveDocument.FormFields("rfacurrent").Result
..Show

End With

End Sub

User sees the auto fill in of TP123456.doc as the file name. They change
it to be saved as
TP123456automaticcomm.doc. It saves the document as
TP123456automaticcomm.doc. BUT the next time they open the document to make
changes, and save it, it changes back to TP23456.doc, and they ahve to
retype the tp123456automaticcomm.docr . How can I tell it to save as
TP123456automaticcommdoc the second + times they save the document?

Thanks,
Linda
 
J

Jezebel

You can check if the file has never been saved by comparing its Name and
FullName -- if these are the same the document has never been saved, so use
your manufactured filename; otherwise use the existing name.

Dim pNewName as string

If ActiveDocument.FullName = ActiveDocument.Name then
pNewName = "TP" & ....
else
pNewName = ActiveDocument.Name
End if

With Dialogs(..)
.Name = pNewName
:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top