ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   File name into a variable (https://www.excelbanter.com/excel-programming/305324-file-name-into-variable.html)

Tim[_20_]

File name into a variable
 
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

No Name

File name into a variable
 
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?

-----Original Message-----
Hi,

Supposing the variable is called 's', you would do:

Dim s As String
s = ThisWorkbook.name

Regards,

Alex

"Tim" wrote:

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

.


Mauro Gamberini

File name into a variable
 
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


--
----------------------------
Mauro Gamberini



Alex Guardiet

File name into a variable
 
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.

" wrote:

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?

-----Original Message-----
Hi,

Supposing the variable is called 's', you would do:

Dim s As String
s = ThisWorkbook.name

Regards,

Alex

"Tim" wrote:

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

.




All times are GMT +1. The time now is 08:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com