+ Reply to Thread
Results 1 to 6 of 6

Open workbook works on stepping but not on execute

  1. #1
    Registered User
    Join Date
    06-13-2011
    Location
    Neston, England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    38

    Open workbook works on stepping but not on execute

    Hi all,

    I have a function that loads an excel workbook and steps through its sheets creating a sheet of the same name in the workbook that the macro resides in. When I execute it, it just does nothing aside from load the workbook. When I put the breakpoint on the load line and execute, then single step through the code it works fine. Setting a breakpoint on any line after the load does nothing. This has had me scratching my head for hours. I can't find anything on the web. Where am I going wrong?

    Please Login or Register  to view this content.
    Any help much appreciated

    Marc

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Open workbook works on stepping but not on execute

    hmmm... a stop at "set awb..." does nothing? I guess your workbook with the macro only has one sheet? because i see that is a condition for the rest to run.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    06-13-2011
    Location
    Neston, England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    38

    Re: Open workbook works on stepping but not on execute

    It does not even do the debug print and yes it does only have one sheet. As I say works fine if I put a breakpoint on the open and step through from there, but not if I just let the macro run. My thoughts are that the file is not loaded when it gets to the set awb= and hence it gets confused. That does not explain why the msgbox does not appear and the debug print does not print. Maybe it is confused as to which workbook is running the code in some way?

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Open workbook works on stepping but not on execute

    How are you executing this code?
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    06-13-2011
    Location
    Neston, England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    38

    Re: Open workbook works on stepping but not on execute

    You would not believe the solution!!! I cannot believe I wasted 2 hours on this!!!

    http://support.microsoft.com/kb/212074/en-us

    don't add a shift in your macro. How the hell that messes up an open, but it does!

  6. #6
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Open workbook works on stepping but not on execute

    lol, too funny. Had no idea it was being run that way, but still wouldn't have thought of it... of course holding shift while opening a workbook prevents auto_open macros from running, so it makes sense I suppose..

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Excel-to-eMail Code Works Only When Stepping Through
    By EnigmaMatter in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-26-2014, 11:19 PM
  2. Vba to open excel in timely schedule and execute macro inside the workbook
    By tantcu in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-23-2013, 10:48 PM
  3. Replies: 0
    Last Post: 03-22-2012, 04:05 PM
  4. Automatically execute a CTRL-ALT-F9 when I open a workbook
    By Antonio Duarte in forum Excel General
    Replies: 1
    Last Post: 06-15-2005, 10:05 AM
  5. Code works when stepping through, but cuts out when run
    By Reenen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-21-2005, 07:47 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1