Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Call Code (2003 SP2)

    How do I call a macro from a child file? I have a master file which opens a child file, then does a

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Call Code (2003 SP2)

    Why not replace ActiveWorkbook.RefreshAll with

    ActiveWorkbook.Sheets(2).QueryTables(1).Refresh BackgroundQuery:=False

    Setting the BackgroundQuery argument to False means that code execution will pause until the rows have been updated.

  3. #3
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Call Code (2003 SP2)

    If the backgroundquery property of the querytable is set to False, then the code should wait until the refresh is completed anyway. You can use the Workbook's RunAutoMacros method:
    <pre>Workbooks.Open Filename:=NewFN
    ActiveWorkbook.RunAutoMacros xlAutoOpen
    ActiveWorkbook.RefreshAll
    </pre>


    to run your AutoOpen code,or move the code from the AutoOpen routine to the Workbook_Open event in the ThisWorkbook module. I don't think this will help if the backgroundquery property is set to True though.
    HTH.
    Regards,
    Rory

    Microsoft MVP - Excel

  4. #4
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Call Code (2003 SP2)

    Thanks gents, excellent as always!
    Much appreciated.

Posting Permissions

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