Disable Error Messages (Macro Scheduler and VB)

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Dominic_Fichera
Pro Scripter
Posts: 82
Joined: Mon Mar 24, 2014 12:15 pm

Disable Error Messages (Macro Scheduler and VB)

Post by Dominic_Fichera » Thu Oct 15, 2015 12:42 am

Hey guys,

I have a script I'm running which will search Excel for specific data. If it can't find that data (which is a valid option) the script presents an error to the users. I know where the errors are caused, but not how to stop them.

Since I am working with users who are likely to "freak out" (for lack of a better word) when this error appears, I want to know if there's anyway to disable the errors from appearing at all and then I can work on creating custom error messages myself.

I have already tried an "OnEvent" to close the error messages as they appear, but I am guessing that since the messages are modal, it prevents the script from activating this command until the error is dismissed... and then it's too late anyway.

The error messages encountered when someone searches for content which does not exist are the below:

Image

Thanks :)

Dominic Fichera

hagchr
Automation Wizard
Posts: 331
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: Disable Error Messages (Macro Scheduler and VB)

Post by hagchr » Thu Oct 15, 2015 8:28 am

Hi, have you tried:

Code: Select all

On Error Resume Next
or

Code: Select all

Application.DisplayAlerts = False
?

Dominic_Fichera
Pro Scripter
Posts: 82
Joined: Mon Mar 24, 2014 12:15 pm

Re: Disable Error Messages (Macro Scheduler and VB)

Post by Dominic_Fichera » Fri Oct 16, 2015 1:17 am

Hey hagchr,

Where would I put that in the grand scheme of things:

Code: Select all

VBSTART
  Dim xlApp
  Dim xlBook
  Sub GetXL
    Set xlApp = GetObject("FILEPATH").Application
    Set xlBook = xlApp.ActiveWorkbook
  End Sub
 
  Function FindCell(Sheet,Data)
    Dim theCell
    Dim xlValues
    xlValues = -4163
 
    Dim xlSheet
    Set xlSheet = xlBook.Worksheets(Sheet)
    xlSheet.Range("A1").Select
    Set theCell = xlSheet.Cells.Find(Data, xlApp.ActiveCell, xlValues)
    FindCell = CStr(theCell.Row) & ":" & CStr(theCell.Column)
  End Function
VBEND
I tried just at the beginning of the VB section, but no dice.

Thanks,

Dominic Fichera

Dominic_Fichera
Pro Scripter
Posts: 82
Joined: Mon Mar 24, 2014 12:15 pm

Re: Disable Error Messages (Macro Scheduler and VB)

Post by Dominic_Fichera » Fri Oct 16, 2015 3:54 am

Very slack of me! I answered my own question with some Googling.

FYI for anyone re-reading this post, it goes the line before the code that causes the error:

Code: Select all

    on error resume next
    FindCell = CStr(theCell.Row) & ":" & CStr(theCell.Column)
Thanks,

Dominic Fichera

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Re: Disable Error Messages (Macro Scheduler and VB)

Post by armsys » Fri Oct 16, 2015 4:55 am

Dominic_Fichera wrote:...FYI for anyone re-reading this post, it goes the line before the code...
Hi Dominic,
Thank you for sharing your working solution.

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts