Macro/VBA to generate and save filenames

T

Trouvera52

I would like to generate and save filenames in a unique way something like:
Prefix_datetimestamp. Can I do this be recording a macro or would VBA be
necessary? Would really appreciate a pointer in the right direction.

Thanks,
Trouvera

P.S. I will be doing this in Word and Excel.
 
J

Jezebel

All macros are VBA, whether you write them or record them. But you can't do
what you describe using the macro recorder.

Dim pFileName as string

pFileName = "Prefix_" & format$(Now, "yyyymmdd")
ActiveDocument.SaveAs FileName:=pFileName
 
T

Trouvera52

Thank you Jezebel.

Jezebel said:
All macros are VBA, whether you write them or record them. But you can't do
what you describe using the macro recorder.

Dim pFileName as string

pFileName = "Prefix_" & format$(Now, "yyyymmdd")
ActiveDocument.SaveAs FileName:=pFileName
 

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