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



Currently within my VB I have

Windows("FileA.xls").Activate

This is no good as the file name will change depending upon which book I
have open, but I want the macro to run on the active book (I will
specify sheet which is the same in all books)

I want to activate current Book.

(there will only be one file active, Macro is running from Personal
Book, which it goes into to copy and paste some data across to File A)

Any ideas?

Thanks

D

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Activate "current workbook"

Set a workbook object = to the current workbook something like this

dim wbkCurrent as workbook

set wbkCurrent = activeworkbook

You now have a refence that workbook that you can access at any time even if
you activate other workbooks subsequent to this declaration.
--
HTH...

Jim Thomlinson


"Darin Kramer" wrote:



Currently within my VB I have

Windows("FileA.xls").Activate

This is no good as the file name will change depending upon which book I
have open, but I want the macro to run on the active book (I will
specify sheet which is the same in all books)

I want to activate current Book.

(there will only be one file active, Macro is running from Personal
Book, which it goes into to copy and paste some data across to File A)

Any ideas?

Thanks

D

*** Sent via Developersdex http://www.developersdex.com ***

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Activate "current workbook"

The activeworkbook does not need to be activated. It is already active.

in any event, you could use

Activeworkbook.Activate

--
Regards,
Tom Ogilvy



"Darin Kramer" wrote in message
...


Currently within my VB I have

Windows("FileA.xls").Activate

This is no good as the file name will change depending upon which book I
have open, but I want the macro to run on the active book (I will
specify sheet which is the same in all books)

I want to activate current Book.

(there will only be one file active, Macro is running from Personal
Book, which it goes into to copy and paste some data across to File A)

Any ideas?

Thanks

D

*** Sent via Developersdex http://www.developersdex.com ***



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Activate "current workbook"

What's wrong with

workbooks("FileA.xls").Activate

--
HTH

Bob Phillips

"Darin Kramer" wrote in message
...


Currently within my VB I have

Windows("FileA.xls").Activate

This is no good as the file name will change depending upon which book I
have open, but I want the macro to run on the active book (I will
specify sheet which is the same in all books)

I want to activate current Book.

(there will only be one file active, Macro is running from Personal
Book, which it goes into to copy and paste some data across to File A)

Any ideas?

Thanks

D

*** Sent via Developersdex http://www.developersdex.com ***



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 397
Default Activate "current workbook"


Hi Bob,

The problem is the sheet name is not always file a, it could be
anything, I just want excel to go to the previous sheet.

ie There will be 3 workbooks visible, :
1) Personal Macro workbook
2) Workbook called XYZ (always visible)
3) Workbook called File A (or File B or file C etc...)

What I am trying to do is copy sheet called Summary from Workbook called
XYZ into item 3 listed above (ie into the workbook NOT called xyz and
NOt Personal)

THis may well be impossible...

Thanks

D


*** Sent via Developersdex http://www.developersdex.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
How to Activate "Show all" in a Protected Shared Workbook Anahid Excel Discussion (Misc queries) 1 November 27th 09 01:44 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Functions for "current" & "previous" month to calculate data Priss Excel Worksheet Functions 11 April 15th 08 06:24 PM
=IF((TODAY()-B8)30, "Overdue", "Current"), Kev Excel Discussion (Misc queries) 3 December 16th 05 08:15 PM
Adding "New" "Insert" "Delete" into a workbook to change from data 1 to data 2 etc Bob Reynolds[_2_] Excel Programming 0 March 4th 04 08:52 PM


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