Thanks Thanks:  0
Likes Likes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: VBA stopping w/ no Error?

  1. #1
    Board Regular
    Join Date
    Apr 2002
    Location
    A Mile High!!
    Posts
    241
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Does anyone know why a VBA would stop with out an error? It just runs and then stops in the middle of what it is doing? Here is the code:
    If Range("c18").Value Then
    Application.ScreenUpdating = False
    Workbooks.Open FileName:= _
    "\serverfolderMaterialsJimFJim.xls", _
    UpdateLinks:=3, WriteResPassword:="jim"
    'check to see if read only
    If ActiveWorkbook.ReadOnly Then
    ActiveWorkbook.Saved = True
    ActiveWorkbook.Close
    Range("e18").Select
    Application.ScreenUpdating = True
    ActiveCell.FormulaR1C1 = "Not Updated"
    GoTo lastlinejim:
    End If
    'update file
    Range("a1").Select
    ActiveWorkbook.Save
    ActiveWindow.Close
    Range("i18").Select
    ActiveCell.FormulaR1C1 = "Updated"
    Application.ScreenUpdating = True
    lastlinejim:
    Range("a1").Select

    End If
    'displayed if not selected
    If Range("c18") <> "True" Then
    Range("e18").Select
    ActiveCell.FormulaR1C1 = "Not Selected"

  2. #2
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Perhaps you may need to clarify what it is that you're asking.

    Is it raising an error? If it isn't, one way code stops running without an error is that there are no errors in the code. (this is the aim of every programmer )

    Is the code just crapping out and not letting you debug?

  3. #3
    Board Regular
    Join Date
    Apr 2002
    Location
    A Mile High!!
    Posts
    241
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Nope it just stops. It runs along and then just quits in the middle of the process. What is weird is that it doesnt do it on my other machine. But I have this problem on the machines of the people I did this for too. It is just one file in a list that this is a part of. If I have selections made after it, it doesnt go on to those. Any ideas?

  4. #4
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Any idea which line it stops at?

    You can step through the code one line at a time.

    Got to the VBE.
    Right click on a toolbar at the top, choose Debug.
    Go to the sub with this code in it and put the cursor somewhere in the code.
    On the Debug toolbar, hit the "Step Into" button (button beside the hand) to run the code one line at a time.

    Do this and you'll find out which line of code it craps out on.

  5. #5
    Board Regular
    Join Date
    Apr 2002
    Location
    A Mile High!!
    Posts
    241
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    It is stopping just after 'update file.

    I tried the stepping through and it went all the way through. Is this maybe just a flukey thing? Now its not doing it all the time. Oh crap.

    [ This Message was edited by: EdE on 2002-05-07 11:11 ]

  6. #6
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Is the workbook always read only? If it's read only, you're effectively telling the macro to end by sending it to the label "lastlinejim".

    Are you open to suggestions for "improving" the code?

  7. #7
    Board Regular
    Join Date
    Apr 2002
    Location
    A Mile High!!
    Posts
    241
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    It is never read only because you need to enter passwords to even open. I am having this problem on several versions of this, that is I created a template for ease of use to other programs. But I never had a problem with this until yesterday. Any improvement suggestions would be welcomed for sure!!

    Thanks!

  8. #8
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Why have this line if it's never Read Only?

    If ActiveWorkbook.ReadOnly Then 


    I'll have a better look at this tomorrow, but it seems like you only need about 5 lines of code. Code you tell me exactly what this code is supposed to be?

  9. #9
    Board Regular
    Join Date
    Apr 2002
    Location
    A Mile High!!
    Posts
    241
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Sorry Mark. I shouldnt have said it is never read only. It is supposed to just open the file to update links and then closes. If it is opened as read only, it skips to the end and goes on to the next one. Any guesses?

    [ This Message was edited by: EdE on 2002-05-10 09:32 ]

  10. #10
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I don't understand this bit of code from your original post:


    'displayed if not selected
    If Range("c18") <> "True" Then
    Range("e18").Select
    ActiveCell.FormulaR1C1 = "Not Selected"


    Is this in another subroutine or something?

    EDIT:: Scratch that, never mind, I just can't read.
    _________________
    [b] Mark O'Brien

    [ This Message was edited by: Mark O'Brien on 2002-05-10 09:11 ]

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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