Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run VBScript from Excel Amy M Excel Discussion (Misc queries) 4 September 19th 08 09:07 PM
vbscript and Excel HSalim[MVP] Excel Programming 8 April 12th 07 08:02 PM
Excel & VBScript Bill Ebbing Excel Programming 7 September 8th 05 06:27 PM
Removing Add-ins programmatically from Excel 2003 using VBScript Dutch Gemini Excel Programming 3 August 30th 05 03:00 PM
Using excel through vbscript ashtom1 Excel Programming 6 July 6th 05 02:55 PM


All times are GMT +1. The time now is 06:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"