ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel 2003 VBScript (https://www.excelbanter.com/excel-programming/400689-excel-2003-vbscript.html)

rchan11

Excel 2003 VBScript
 
Hi,

I need some help in finding the file name of the currently opened worksheet
in excel. Is there an easy function such as Environ() that can be used to
find the current opened file?

Thanks,
Ryan

Gary''s Student

Excel 2003 VBScript
 
Sub ordinate()
MsgBox (ActiveSheet.Name)
End Sub

for the sheet name

Sub ordinate()
MsgBox (ActiveWorkbook.Name)
End Sub

for the workbook name
--
Gary''s Student - gsnu200753


"rchan11" wrote:

Hi,

I need some help in finding the file name of the currently opened worksheet
in excel. Is there an easy function such as Environ() that can be used to
find the current opened file?

Thanks,
Ryan


Chip Pearson

Excel 2003 VBScript
 
You can reference either of two files directly: the object ActiveWorkbook is
a reference to the workbook that is active in the main Excel window. This
may not be the same workbook that contains the executing code. The
ThisWorkbook object refers to the workbook containing the executing code,
which may not be the same workbook that is active in the main Excel window.
From either of these you can use the Name or FullName properties to get the
Name (file name without drive or directory info) or the complete file name
(including drive and folder information). E.g.,

Debug.Print ActiveWorkbook.Name
Debug.Print ThisWorkbook.FullName


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"rchan11" wrote in message
...
Hi,

I need some help in finding the file name of the currently opened
worksheet
in excel. Is there an easy function such as Environ() that can be used to
find the current opened file?

Thanks,
Ryan



rchan11

Excel 2003 VBScript
 
Thank you very much! I should have searched the forums...I believe the
answer has been posted before.

"Gary''s Student" wrote:

Sub ordinate()
MsgBox (ActiveSheet.Name)
End Sub

for the sheet name

Sub ordinate()
MsgBox (ActiveWorkbook.Name)
End Sub

for the workbook name
--
Gary''s Student - gsnu200753


"rchan11" wrote:

Hi,

I need some help in finding the file name of the currently opened worksheet
in excel. Is there an easy function such as Environ() that can be used to
find the current opened file?

Thanks,
Ryan


John Bundy

Excel 2003 VBScript
 
Sub location()
MsgBox ActiveSheet.Name 'sheet name
MsgBox ActiveWorkbook.Name 'filename
MsgBox ActiveWorkbook.Path 'path

End Sub

--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"rchan11" wrote:

Hi,

I need some help in finding the file name of the currently opened worksheet
in excel. Is there an easy function such as Environ() that can be used to
find the current opened file?

Thanks,
Ryan



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

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