Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Activate Workbook

I've written some code that will be used in a workbook
template. The code creates a new workbook, does some
stuff to it, closes it, and returns to the template. I
was using the following code:

Windows("Template.xls").Activate

But, I've realized that the users will probably be
changing the name of the workbook. How can I always return
to the workbook in which the macro resides?

Thanks in advance!
Fred
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Activate Workbook

Fred,

The ThisWorkbook reference will always refer to the workbook
containing the code. So you can write

ThisWorkbook.Activate


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


"Fred" wrote in message
...
I've written some code that will be used in a workbook
template. The code creates a new workbook, does some
stuff to it, closes it, and returns to the template. I
was using the following code:

Windows("Template.xls").Activate

But, I've realized that the users will probably be
changing the name of the workbook. How can I always return
to the workbook in which the macro resides?

Thanks in advance!
Fred



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
can't seem to activate an open workbook dantee Excel Discussion (Misc queries) 1 July 11th 08 02:48 AM
activate opened workbook via VBA Noemi Excel Discussion (Misc queries) 1 May 3rd 06 01:21 PM
Activate Workbook Dolphinv4 Excel Discussion (Misc queries) 2 October 22nd 05 01:45 PM
Activate new workbook with unknown name rt10516 Excel Discussion (Misc queries) 3 August 24th 05 05:40 AM
Workbook.activate Jeff Excel Discussion (Misc queries) 1 December 13th 04 10:22 PM


All times are GMT +1. The time now is 05:06 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"