Results 1 to 10 of 10
  1. #1
    2 Star Lounger
    Join Date
    May 2005
    Location
    Wilcox, Saskatchewan
    Posts
    171
    Thanks
    0
    Thanked 0 Times in 0 Posts

    code execution error (excel)

    I have here a macro that legare helped me with. I made a few modifications. When I run the code it seems to stop execution, and asks me if Iwould like to continue. Debug stops at this line: For Each wsh2 In wbk.Worksheets
    I have been over looking the code for a hour now and was wondering if anyone can see my mistake.

    sean

  2. #2
    2 Star Lounger
    Join Date
    May 2005
    Location
    Wilcox, Saskatchewan
    Posts
    171
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: code execution error (excel)

    I am thinking my settings in excel are causing the problem is there a way to reset them?

  3. #3
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: code execution error (excel)

    Since I don't know of any situation where VBA "stop(s) execution, and asks me if Iwould like to continue," it is a little hard to guess what is going on. If you went into Debug, then there would have been a message telling you why you went into Debug. If you got such a message, it would be a big help if you told us what the exact message was. The only obvious reason for stopping on the statement you specified would be that wbk was not assigned to a workbook object, but I don't see any obvious reason why that might happen.
    Legare Coleman

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: code execution error (excel)

    First, that code does not look anything like the code in your first message (that code does not contain a Select Case statement), so I am not sure what we are debugging.

    Second, the message box is cut in half, so I can't see the entire message (I don't know if that is the way you posted it or if that is Hans' editing). From what I see of the message, it looks like the message you might get if you hit Ctrl/Break to interrupt code execution. Is that what you did? If so, why? If not, exactly what did happen.

    Third, that looks like the code I fixed in the first post of yours that I replied to in another thread. However, it looks like the code before I posted the corrections. There are several problems in the code that I can see that I fixed before. The similar code that I fixed before is in this <post#=493832>post 493832</post: >.
    Legare Coleman

  5. #5
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: code execution error (excel)

    The code in the picture is not the code you posted in your original post. Could you make sure that you posted the code you are having the problem with?

    The error you are displaying is usually caused by user interruption of the code. It might be wise to have this opening code:

    Application.Enableevents = False

    and be SURE to have

    Application.Enableevents = True

    in the Exithandler section.
    -John ... I float in liquid gardens
    UTC -7ąDS

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

    Re: code execution error (excel)

    The cutting off of the message box is my doing, but there was no more text in the original.

  7. #7
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: code execution error (excel)

    OK, that is what I thought, but I could not be sure from the edited post. That looks very much like Ctrl/Break was hit to interrupt the execution.
    Legare Coleman

  8. #8
    2 Star Lounger
    Join Date
    May 2005
    Location
    Wilcox, Saskatchewan
    Posts
    171
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: code execution error (excel)

    here is a pic ture of the error I get

    Picture reduced in size by HansV - puhleeze don't post pictures over 640 by 480 pixels, they cause scrolling on smaller screens.

  9. #9
    2 Star Lounger
    Join Date
    May 2005
    Location
    Wilcox, Saskatchewan
    Posts
    171
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: code execution error (excel)

    I pasted the wrong picture, Ill correct my post

    I did some more debugging and came up with this error


    ---------------------------
    Microsoft Excel
    ---------------------------
    Object variable or With block variable not set
    ---------------------------
    OK
    ---------------------------
    the debug jumps to exit handler after steping into this line : Set fld = fso.GetFolder(strPath)

  10. #10
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: code execution error (excel)

    If that message goes with the code in your first post in this thread, and you get it on this statement:

    For Each wsh2 In wbk.Worksheets


    Then that says that the object variable wbk has not been assigned a value. This would indicate that for some reason, no workbook was opened two lines before this statement.
    Legare Coleman

Posting Permissions

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