Coding a filename into a macro

G

Guerilla

Hi,

I want to be able to move a selection of sheets to a new workbook, and
name the file (this does not change so I would declare this as a
string - I think), however, I would like the newly created file to be
saved in the current directory (the directory of the original file).
How can I do this?

Also,
In case I don't figure it out, what is the code for setting the
filename in the macro?

kind regards,

Matt
 
J

JE McGimpsey

One way:

Const csFILENAME As String = "MyBook.xls"

With ThisWorkbook
.SaveAs Filename:=.Path & Application.PathSeparator & csFILENAME
End With
 

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