Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 28 of 28

Thread: Solved: Closing Excel Application Problem

  1. #21
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    Exit_Handling is just a label. It's not a separate procedure. You can use lables with goto statements, but otherwise, they're ignored when a procedure is executed.

  2. #22
    Thanks a lot.

  3. #23
    VBAX Regular HRoarke's Avatar
    Joined
    Aug 2005
    Location
    Raleigh, NC and Washington, DC
    Posts
    6
    Location
    You must have an Exit Sub just before the handler label
    Never doubt that a small group of thoughtful, committed people can change the world. Indeed, it is the only thing that ever has.
    --Margaret Mead


  4. #24
    That would work. Thanks.

  5. #25
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    Mr. Roarke, I think that depends on how you choose to handle things, but generally, most people follow this basic model:

    [VBA] Function ProcedureName(ArgumentList) As DataType
    ' Procedure comments.
    ' Declare local variables and constants.

    On Error GoTo ProcedureName_Err
    ' Procedure code.
    .
    .
    .
    ProcedureName = True (or some other return value)
    ProcedureName_End:
    ' Cleanup code that closes open files and sets object variables = Nothing.
    Exit Function
    ProcedureName_Err:
    ProcedureName = False
    Select Case Err.Number
    Case AnticipatedError#1
    ' Handle error #1.
    Case AnticipatedError#2
    ' Handle error #2.
    Case UnAnticipatedErrors
    ' Handle unanticipated error.
    Case Else
    ' Handle unforseen circumstances.
    End Select
    Resume ProcedureName_End
    End Function [/VBA]

    For anyone interested, see http://msdn.microsoft.com/library/de...lingerrors.asp for more details.

  6. #26
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    Quote Originally Posted by JuanDelaCruz
    That would work. Thanks.
    Don't put exit sub before ex2.quit though.

  7. #27
    VBAX Regular HRoarke's Avatar
    Joined
    Aug 2005
    Location
    Raleigh, NC and Washington, DC
    Posts
    6
    Location
    Aye, xCav8r, I have seen and used that form as well. I suggested the simplest approach, based on the original code samples submitted. Thanks for the clarification, though.
    Never doubt that a small group of thoughtful, committed people can change the world. Indeed, it is the only thing that ever has.
    --Margaret Mead


  8. #28
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    Juan, if your problem is solved, can you use the link at the top of this thread (called Threat Tools) to mark this as solved?

Posting Permissions

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