Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default How to: obtain the filename that a module exists in, via VBA?

TWIMC,

When my Auto_Open() kicks off I need to be able to establish the file name.
The reason for this is that when I'm designing my Excel Add in my file name
uses the .xls extension so i refer to my file as FileName.xls but when I want
to save my file as an Excel Add-in, the file extension changes to .xla, thus
I need to update my reference in the code. Therefore it would good if I can
obtain the file name when the Auto_Open() starts, then I don't have to
manualy change the reference.

Any ideas on how to accomplish this would be create.

TIA
KM
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to: obtain the filename that a module exists in, via VBA?

thisworkbook.Path
Thisworkbook.Fullname
Thisworkbook.Name

--
Regards,
Tom Ogilvy

"Kevin McCartney" wrote in
message ...
TWIMC,

When my Auto_Open() kicks off I need to be able to establish the file

name.
The reason for this is that when I'm designing my Excel Add in my file

name
uses the .xls extension so i refer to my file as FileName.xls but when I

want
to save my file as an Excel Add-in, the file extension changes to .xla,

thus
I need to update my reference in the code. Therefore it would good if I

can
obtain the file name when the Auto_Open() starts, then I don't have to
manualy change the reference.

Any ideas on how to accomplish this would be create.

TIA
KM



  #3   Report Post  
Posted to microsoft.public.excel.programming
CH CH is offline
external usenet poster
 
Posts: 49
Default How to: obtain the filename that a module exists in, via VBA?

Hi Tom,

How can we return a workbook's file name with and without extension?

Thanks in advance.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default How to: obtain the filename that a module exists in, via VBA?

Is this what you want?


With Extension:
=============================
ThisWorkbook.Name


Without Extension
=============================
Left(ThisWorkbook.Name, InStrRev(ThisWorkbook.Name, ".") - 1)


--
Rick (MVP - Excel)


"ch" wrote in message
...
Hi Tom,

How can we return a workbook's file name with and without extension?

Thanks in advance.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default How to: obtain the filename that a module exists in, via VBA?

Hi,
you can use

ThisWorkbook.FullName
ThisWorkbook.Name
thisworkbook.Path

eg:
Dim wkb as Workbook
Set Wkb = ThisWorkbook
msgbox wkb.fullname
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Kevin McCartney" wrote:

TWIMC,

When my Auto_Open() kicks off I need to be able to establish the file name.
The reason for this is that when I'm designing my Excel Add in my file name
uses the .xls extension so i refer to my file as FileName.xls but when I want
to save my file as an Excel Add-in, the file extension changes to .xla, thus
I need to update my reference in the code. Therefore it would good if I can
obtain the file name when the Auto_Open() starts, then I don't have to
manualy change the reference.

Any ideas on how to accomplish this would be create.

TIA
KM



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
code in module A to not execute a Worksheet_SelectionChange sub of another module Jack Sons Excel Discussion (Misc queries) 4 December 11th 05 11:52 PM
Run worksheet module code from workbook module? keithb Excel Programming 1 August 14th 05 04:04 AM
Calls from sheet module to ThisWorkbook module quartz[_2_] Excel Programming 2 June 23rd 05 03:37 PM
Check if filename exists. Darrin Henshaw Excel Programming 6 May 5th 05 11:59 PM
Variable from a sheet module in a class module in XL XP hglamy[_2_] Excel Programming 2 October 14th 03 05:48 PM


All times are GMT +1. The time now is 09:52 PM.

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"