VBA for Filename Creation without document Save

B

Barb Reinhardt

I have used a macro which creates a filename and saves the document to this
document name. The statement in the macro is currently:

ActiveDocument.SaveAs FileName:="blahblahblah" & Format(Order, "00#")

I like the way the document is named, but I don't want it saved at this
time. How do I update this statement so that the file is named and opened
only?

Thanks in advance,
Barb Reinhardt
 
J

Jay Freedman

Barb said:
I have used a macro which creates a filename and saves the document
to this document name. The statement in the macro is currently:

ActiveDocument.SaveAs FileName:="blahblahblah" & Format(Order, "00#")

I like the way the document is named, but I don't want it saved at
this time. How do I update this statement so that the file is named
and opened only?

Thanks in advance,
Barb Reinhardt

Hi Barb,

You really can't, because the only time Word actually assigns a file name to
a document is during the save process. No save = no name.

But you can set things up so that your chosen name is suggested in the Save
dialog the first time the document is saved. See
http://word.mvps.org/FAQs/MacrosVBA/SetDefFilename.htm. If you know the name
you want at the time you create the document, put the code from the article
into a macro named AutoNew in the template so it runs right away.
 
B

Barb Reinhardt

That does exactly what I want it to do. Thanks.
Jay Freedman said:
Hi Barb,

You really can't, because the only time Word actually assigns a file name to
a document is during the save process. No save = no name.

But you can set things up so that your chosen name is suggested in the Save
dialog the first time the document is saved. See
http://word.mvps.org/FAQs/MacrosVBA/SetDefFilename.htm. If you know the name
you want at the time you create the document, put the code from the article
into a macro named AutoNew in the template so it runs right away.
 

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