Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA code to call the name of current file

Hi,

I was wondering if anybody knew the VBA code to call the name of th
excel file that contained the module a macro was in?

My issue is that the name of the file changes every month so using

Windows("210 Product Expense Report - August Close.xls").Activate

wont work in september. I was just wondering if there was a way to d
this without using Inputbox and just entering the correct name eac
month.


Thanks

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default VBA code to call the name of current file

ThisWorkbook will always return a reference to the workbook
containing the code. Therefore, you can do something like

ThisWorkbook.Activate
' or
Windows(ThisWorkbook.Name).Activate

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"Phatchef24 " wrote
in message ...
Hi,

I was wondering if anybody knew the VBA code to call the name
of the
excel file that contained the module a macro was in?

My issue is that the name of the file changes every month so
using

Windows("210 Product Expense Report - August
Close.xls").Activate

wont work in september. I was just wondering if there was a
way to do
this without using Inputbox and just entering the correct name
each
month.


Thanks!


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA code to call the name of current file

That did it. Thanks

--
Message posted from http://www.ExcelForum.com

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
Sum Column above current cell dynamically using function call TopSlice Excel Worksheet Functions 7 September 15th 09 02:03 PM
How do I call current computer time to a cell? Carol G. Excel Worksheet Functions 9 November 14th 08 04:37 AM
how can i call sub or function in vba code xxx Excel Discussion (Misc queries) 3 June 28th 06 11:47 AM
call a procedure using current inputs mike allen[_2_] Excel Programming 2 July 2nd 04 12:06 AM
changing current directory to that of the current open file unnameable Excel Programming 2 May 19th 04 11:14 AM


All times are GMT +1. The time now is 03:49 AM.

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

About Us

"It's about Microsoft Excel"