1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Run-time error 91, PLS Help

Discussion in 'Business Applications' started by Muath, Feb 17, 2013.

Thread Status:
Not open for further replies.
Advertisement
  1. Muath

    Muath Thread Starter

    Joined:
    Feb 17, 2013
    Messages:
    3
    ErrHandler:

    If Err.Number = 75 Then

    MsgBox"Folder Already Exists, delete it First then retry.", , Caption

    ElseIf Err.Number = 76 Then

    MsgBox "Thepath is invalid!", , Caption

    ElseIf Err.Number=91 Then

    MsgBox "Object variable or with block variable notset", , Caption

    Else

    MsgBox "Error Occuredduring processing and thus worksheet " _

    & ThisYearSheet.Name & " INworkbook " & ThisYearbook.Name _

    & " Cannot be processed "& vbCrLf & Err.Description, , Err.Number

    Resume Continue1

    End If

    End Sub
     
  2. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,912
    Please post ALL of your code not just the error handling portion. Also provide an explanation of what your macro is supposed to do as well as what application you are running it from. It would also be much more efficient to use a SELECT statement instead of multiple IF statements to handle your errors. I've shown an example of how to use a SELECT statement below but will still need to see your entire code to determine why the error is being thrown in the first place.

    Code:
    ErrHandler:
    
    Select Case Err.Number
    
    Case 75
    MsgBox "Folder Already Exists, delete it First then retry.", , Caption
    
    Case 76
    MsgBox "Thepath is invalid!", , Caption
    
    Case 91
    MsgBox "Object variable or with block variable notset", , Caption
    
    Case Else
    MsgBox "Error Occuredduring processing and thus worksheet " _
    & ThisYearSheet.Name & " INworkbook " & ThisYearbook.Name _
    & " Cannot be processed " & vbCrLf & Err.Description, , Err.Number
    
    Resume Continue1
    
    End Select
    Rollin
     
  3. Muath

    Muath Thread Starter

    Joined:
    Feb 17, 2013
    Messages:
    3
    Dear Rollin,
    thanks for your reply, actually the program is old one done on office 2003 and this problem occurs only when running it on newer version of office while on office 2003 it runs with les troubles though it has some errors on it,
    the error message with yellow color appears for the part:
    Case 91
    MsgBox "Object variable or with block variable notset", , Caption

    Case Else
    MsgBox "Error Occuredduring processing and thus worksheet " _
    & ThisYearSheet.Name & " INworkbook " & ThisYearbook.Name _
    & " Cannot be processed " & vbCrLf & Err.Description, , Err.Number
     
  4. Muath

    Muath Thread Starter

    Joined:
    Feb 17, 2013
    Messages:
    3
    kindly how i can see your example i am new to the site
     
  5. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,912
    We need to see your entire code not just the error handling portion.


    Rollin
     
  6. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1089922

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice