File name into a variable

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

In an excel macro, how can I place the name of the file I
am working on into a variable?

Thanks for your help in advance,
Tim
 
The code gives the name of the VB file, not the excel
file. Is there a way to give the name of the excel file?
 
The code gives the name of the VB file, not the excel
file. Is there a way to give the name of the excel file?
???????

Public Sub myFile()
Dim s As String
s = ThisWorkbook.Name
MsgBox (s)
End Sub
 
No it does not. It gives the name of the excel file. "ThisWorkbook" means "this excel file". Please try out the code before replying, as you mislead other users.
 

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

Back
Top