Results 1 to 12 of 12
  1. #1
    New Lounger
    Join Date
    May 2013
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Force Web Pull Macro to Run First

    Hi

    After WorkBook Automatically Re-Opens I Need Web Pull Set to Run First

    That's all

    This is a set up example Wb


    (Please View, Wb and Click One Button To See How It Currently Runs and How It Should Run)


    Appreciate thought through assistance of Course


    Cheers Mike
    Attached Files Attached Files
    Last edited by keen2xl; 2013-11-09 at 04:14.

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 341 Times in 334 Posts
    Could you describe what you want to happen order routines are meant to run. There does not appear to be an autoroutine, so you can run any macro whenever you want. I don't understand the need to close and re-open the routine.

    Steve

  3. #3
    New Lounger
    Join Date
    May 2013
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi Steve

    I am Closing Wb down then opening again after each race to wait for the results to come in.

    On Re-opening the Results have come in so the first thing i need the Wb to do is down load the results, then the Wb copies them over to other areas of the actual Wb for use.

    Trouble i am having is

    Sub OpenMe()

    Calls "Results_Updated_Run_1st" first in Order as it is in the attached Wb

    then for this Example it Calls second "Text_Run____________2nd" as in order in the attached Wb.

    But it doesn't run in that set order, it processes "Text_Run____________2nd" first which i don't want.

    Hope that makes sense.

    Sooo needed is some brainy person to firure out how to force "Results_Updated_Run_1st" to process first

    Cheers




    Sub CloseMe()



    Application.OnTime Now + TimeValue("00:00:04"), "OpenMe"


    Call ClearText


    ThisWorkbook.Close SaveChanges:=True



    End Sub

    Sub OpenMe()

    Call Results_Updated_Run_1st

    Call Text_Run____________2nd

    End Sub

  4. #4
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 341 Times in 334 Posts
    Instead of using the OpenMe routine, why not call the Results_Updated_Run_1st routine from the CloseMe routine directly.
    Add the line "Call Text_Run____________2nd" at the end of "Results_Updated_Run_1st" routine...

    Steve

  5. #5
    New Lounger
    Join Date
    May 2013
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Results take varying times to come in.


    On Re-Open via "Close me" Macro, "Open me" is what is called as part of the "Close me" / "Open me" Macro routine, inside the "Open me" Macro "Results_Updated_Run_1st" routine is placed 1st in order, underneath it is "Text_Run____________2nd" that is 2nd in order.

    These are needed and that's all.

    1/ Wb Closes.
    2/ Wb re-opens automatically
    3/ "Results_Updated_Run_1st" is the 1st Macro to run

    Is this possible ?

    Cheers

  6. #6
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 341 Times in 334 Posts
    I thought That is what I suggested that you do.

    I proposed that instead of reopening and running OpenMe it, you eliminate that routine altogether.
    The closeme routine whould reopen and run "Results_Updated_Run_1st"
    and at the end of that routiine it would call "Text_Run____________2nd"

    Steve

  7. #7
    New Lounger
    Join Date
    May 2013
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    How would it call "Text_Run____________2nd" if it is not in the "Close me" macro and "Results_Updated_Run_1st" has replaced "OpenMe"

  8. #8
    New Lounger
    Join Date
    May 2013
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    It doesn't matter where i put "Results_Updated_Run_1st" Macro or which one is in what order the Macro that doesn't have external Data to retrieve is run 1st.

  9. #9
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 341 Times in 334 Posts
    My instructions included:
    Add the line "Call Text_Run____________2nd" at the end of "Results_Updated_Run_1st" routine...

    But after thinking about it, i think the problem is that you are updated the query in the background, which means the code will all run through in either case, before the query is finished. you probably need to NOT refresh in the background.

    Try changing the line to:
    .Refresh BackgroundQuery:=False

    This will probably work even in your current setup.
    Steve
    Your macro IS running in the correct order (you can verify thhis by adding some message boxes at the start and end of the procedures), it just is not refreshing the query before the 2nd macro starts since it set to run in the background...
    Last edited by sdckapr; 2013-11-09 at 07:53.

  10. The Following User Says Thank You to sdckapr For This Useful Post:

    keen2xl (2013-11-09)

  11. #10
    New Lounger
    Join Date
    May 2013
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Looks promising, tried that simple solution and sure enough results are updated before screen is even loaded and Text runs 2nd so will try on actual Wb when races start later today.

    Thanks for your help kind Sir

    Patience for me at least, is sometimes a challenge but it works better than lack of : )

    Respect to you

    Peace
    Last edited by keen2xl; 2013-11-09 at 15:31.

  12. #11
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 341 Times in 334 Posts
    Just to clarify:
    Your macros WERE running in the order you wanted them to.
    In the 1st macro code, you set options for query and had the query to refresh in the background.
    When that was complete, the 2nd macro ran.

    But what you wanted was the 1st macro to run, set the options and the refresh the query BEFORE the 2nd macro was started. This not what you had the code do and hopefully it is what I had the code do.

    Steve

  13. #12
    New Lounger
    Join Date
    May 2013
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Have tried on Actual Wb and it works so yes you cracked it : )

    I had all-sorts of suggestions, it took me a good week of posting, waiting testing, re posting waiting etc etc, but persevered and hey presto got the answer eventually.

    So thanks again, you are a good man.

    Cheers

    Mike : )

Tags for this Thread

Posting Permissions

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