Results 1 to 6 of 6

Thread: Open And Activate Workbook Before Runing Macro

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    14
    If each workbook contains an 'auto' macro this will suffice (since an 'auto' macro runs automatically when opening the file...)
    Code:
    Sub M_snb()
        with getobject("C:\My Documents\BR1 parts sales.xlsm")
            .close true
        end with
        with Getobject("C:\My Documents\Br1 service sales.xlsm")
           .close true
        end with
    End Sub
    PS. Avoid 'Select' and 'Activate' in VBA.
    Last edited by snb; 06-04-2013 at 03:44 PM.

Similar Threads

  1. Excel VBA Macro To Open A File Through Browse Dialog Box
    By Safal Shrestha in forum Excel Help
    Replies: 2
    Last Post: 04-05-2013, 12:59 PM
  2. VBA Code to Open Workbook and copy data
    By Howardc in forum Excel Help
    Replies: 16
    Last Post: 08-15-2012, 06:58 PM
  3. Replies: 8
    Last Post: 08-05-2012, 10:07 AM
  4. Get Name List of All Open Workbook Files
    By princ_wns in forum Excel Help
    Replies: 5
    Last Post: 04-07-2012, 12:18 PM
  5. Assign an event to chart on workbook open
    By LalitPandey87 in forum Excel Help
    Replies: 2
    Last Post: 02-20-2012, 07:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •