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:
Thanks
Dominic Fichera
Disable Error Messages (Macro Scheduler and VB)
Moderators: Dorian (MJT support), JRL
-
- Pro Scripter
- Posts: 82
- Joined: Mon Mar 24, 2014 12:15 pm
Re: Disable Error Messages (Macro Scheduler and VB)
Hi, have you tried:
or ?
Code: Select all
On Error Resume Next
Code: Select all
Application.DisplayAlerts = False
-
- Pro Scripter
- Posts: 82
- Joined: Mon Mar 24, 2014 12:15 pm
Re: Disable Error Messages (Macro Scheduler and VB)
Hey hagchr,
Where would I put that in the grand scheme of things:
I tried just at the beginning of the VB section, but no dice.
Thanks,
Dominic Fichera
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
Thanks,
Dominic Fichera
-
- Pro Scripter
- Posts: 82
- Joined: Mon Mar 24, 2014 12:15 pm
Re: Disable Error Messages (Macro Scheduler and VB)
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:
Thanks,
Dominic Fichera
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)
Dominic Fichera
Re: Disable Error Messages (Macro Scheduler and VB)
Hi Dominic,Dominic_Fichera wrote:...FYI for anyone re-reading this post, it goes the line before the code...
Thank you for sharing your working solution.