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

I was given a spreadsheet for 1st Quarter with a drop-down ment that
calls a macro that recalcs all my pivot tables and one of the first
items in that procedure is ThisWorkbook.Activate.

I copied the whole workbook and made one for 2nd Quarter.

If I open the 1st Quarter one and the menu appears, and then I open
the 2nd Quarter one... there is still only one menu (as they are
exactly the same)... if I click the menu and run the macro, which
workbook will it run on?

I envision one of three possible answers: the first one I opened, the
last one I opened, whichever workbook was active.

Help!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default ThisWorkbook.Activate Question

thisworkbook refers to the workbook that holds the code.

Look at the properties of the menu button and see which macro is assigned to
the button.

--
Regards,
Tom Ogilvy


" wrote:

I was given a spreadsheet for 1st Quarter with a drop-down ment that
calls a macro that recalcs all my pivot tables and one of the first
items in that procedure is ThisWorkbook.Activate.

I copied the whole workbook and made one for 2nd Quarter.

If I open the 1st Quarter one and the menu appears, and then I open
the 2nd Quarter one... there is still only one menu (as they are
exactly the same)... if I click the menu and run the macro, which
workbook will it run on?

I envision one of three possible answers: the first one I opened, the
last one I opened, whichever workbook was active.

Help!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default ThisWorkbook.Activate Question

Unfortunately, both workbooks hold the exact same code. If I open
either workbook, I get the one menu. However, if I open both workbooks
at once, I only get one menu. Which workbooks menu am I seeing?

On Jul 5, 10:38 am, Tom Ogilvy
wrote:
thisworkbook refers to the workbook that holds the code.

Look at the properties of the menu button and see which macro is assigned to
the button.

--
Regards,
Tom Ogilvy



" wrote:
I was given a spreadsheet for 1st Quarter with a drop-down ment that
calls a macro that recalcs all my pivot tables and one of the first
items in that procedure is ThisWorkbook.Activate.


I copied the whole workbook and made one for 2nd Quarter.


If I open the 1st Quarter one and the menu appears, and then I open
the 2nd Quarter one... there is still only one menu (as they are
exactly the same)... if I click the menu and run the macro, which
workbook will it run on?


I envision one of three possible answers: the first one I opened, the
last one I opened, whichever workbook was active.


Help!- Hide quoted text -


- Show quoted text -



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default ThisWorkbook.Activate Question

Add a line like:
msgbox thisworkbook.fullname

So you can see.

===
If you're duplicating code in multiple workbooks, it may be time to move the
code into a single workbook (an addin). Then run against the activesheet or
activeworkbook.

One good thing about this is that when the code needs to change--and it will or
you need a new data workbook, you don't need to update a bunch of workbooks.



wrote:

Unfortunately, both workbooks hold the exact same code. If I open
either workbook, I get the one menu. However, if I open both workbooks
at once, I only get one menu. Which workbooks menu am I seeing?

On Jul 5, 10:38 am, Tom Ogilvy
wrote:
thisworkbook refers to the workbook that holds the code.

Look at the properties of the menu button and see which macro is assigned to
the button.

--
Regards,
Tom Ogilvy



" wrote:
I was given a spreadsheet for 1st Quarter with a drop-down ment that
calls a macro that recalcs all my pivot tables and one of the first
items in that procedure is ThisWorkbook.Activate.


I copied the whole workbook and made one for 2nd Quarter.


If I open the 1st Quarter one and the menu appears, and then I open
the 2nd Quarter one... there is still only one menu (as they are
exactly the same)... if I click the menu and run the macro, which
workbook will it run on?


I envision one of three possible answers: the first one I opened, the
last one I opened, whichever workbook was active.


Help!- Hide quoted text -


- Show quoted text -


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default ThisWorkbook.Activate Question

Depends, if the code deletes the menu before re-creating it, it will be the
second. If it doesn't, the second probably fails when creating it.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

wrote in message
ups.com...
I was given a spreadsheet for 1st Quarter with a drop-down ment that
calls a macro that recalcs all my pivot tables and one of the first
items in that procedure is ThisWorkbook.Activate.

I copied the whole workbook and made one for 2nd Quarter.

If I open the 1st Quarter one and the menu appears, and then I open
the 2nd Quarter one... there is still only one menu (as they are
exactly the same)... if I click the menu and run the macro, which
workbook will it run on?

I envision one of three possible answers: the first one I opened, the
last one I opened, whichever workbook was active.

Help!





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default ThisWorkbook.Activate Question

On Jul 5, 11:12 am, "Bob Phillips" wrote:
Depends, if the code deletes the menu before re-creating it, it will be the
second. If it doesn't, the second probably fails when creating it.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

wrote in message

ups.com...



I was given a spreadsheet for 1st Quarter with a drop-down ment that
calls a macro that recalcs all my pivot tables and one of the first
items in that procedure is ThisWorkbook.Activate.


Thanks.. I looked at the code and it does indeed delete it first.
Therefore the most recently opened one would be the one.

I copied the whole workbook and made one for 2nd Quarter.


If I open the 1st Quarter one and the menu appears, and then I open
the 2nd Quarter one... there is still only one menu (as they are
exactly the same)... if I click the menu and run the macro, which
workbook will it run on?


I envision one of three possible answers: the first one I opened, the
last one I opened, whichever workbook was active.


Help!- Hide quoted text -


- Show quoted text -



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
Activate Object question Eva Excel Worksheet Functions 0 December 14th 07 12:41 AM
ThisWorkbook.Print question Dave Excel Discussion (Misc queries) 1 November 19th 07 05:55 PM
'ThisWorkbook' Macro Question Dan R. Excel Programming 9 January 19th 07 06:16 PM
ThisWorkbook module question Stuart[_5_] Excel Programming 3 July 17th 04 02:32 PM


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