ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Filename prgramatically (https://www.excelbanter.com/excel-programming/295334-excel-filename-prgramatically.html)

Mike D[_3_]

Excel Filename prgramatically
 
I have a line of code:

strThisFileName = "MY Excel FileName.xls"

How do I set my variable to the current excel filename?

strThisFileName = Workbooks.??

Thanks
Mike

Toby Erkson

Excel Filename prgramatically
 
Use ThisWorkbook.Name

To get the path:
ThisWorkbook.Path

So your code would be:
strThisFileName = Thisworkbook.Name

Toby Erkson
Oregon, USA

On Fri, 16 Apr 2004 10:51:40 -0700, "Mike D" wrote:

I have a line of code:

strThisFileName = "MY Excel FileName.xls"

How do I set my variable to the current excel filename?

strThisFileName = Workbooks.??

Thanks
Mike



Frank Kabel

Excel Filename prgramatically
 
Hi
strThisFileName = Activeworkbook.name

--
Regards
Frank Kabel
Frankfurt, Germany


Mike D wrote:
I have a line of code:

strThisFileName = "MY Excel FileName.xls"

How do I set my variable to the current excel filename?

strThisFileName = Workbooks.??

Thanks
Mike


Mike D[_3_]

Excel Filename prgramatically
 
NeverMind

ThisWorkbook.Name
-----Original Message-----
I have a line of code:

strThisFileName = "MY Excel FileName.xls"

How do I set my variable to the current excel filename?

strThisFileName = Workbooks.??

Thanks
Mike
.


Matthew =}[_2_]

Excel Filename prgramatically
 
Hey, Mike.

Your Workbooks.??? method will DO something to the
workbook. You want to ask it something, I think.

strThisFileName = ActiveWorkbook.Name
strThisSheetName = ActiveSheet.Name

....assuming the reference is to an open workbook with an
active sheet. Before I run these lines, I reassure
myself with something like:

Range("C3").Select
Range("C3").Activate

Then the cell (or range) you have activated will also
activate that sheet and the book that contains it.

You may also have interest in:

ActiveWorkbook.SaveAs (strThisNewFileName)
ActiveWorkbook.Close

Anyway, I hope that's what you were looking for.

Good luck, it sounds like fun.

Matthew

=}




-----Original Message-----
I have a line of code:

strThisFileName = "MY Excel FileName.xls"

How do I set my variable to the current excel filename?

strThisFileName = Workbooks.??

Thanks
Mike
.



All times are GMT +1. The time now is 10:22 AM.

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