File name into a variable

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
 
G

Guest

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?
 
M

Mauro Gamberini

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
 
A

Alex Guardiet

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.
 
Top