Hello,
I am getting an error on a line that just has resume on it after an errhandler
I have a workbook that I use to write invoices. Every time I open it, it adds 1 to the invoice number, saves the workbook, opens an input box that asks the user to enter the job name, then saves the workbook under a different name using the users input.
The problem is that some of our job names have an "/" in them, which causes an invalid file name.
To solve this I added an "on error" that would open another input box that states all the invalid characters and then asks the user to re-enter the job name then resumes on the line that saves the file.
when I do this I get an error on the resume and it either gives me an error or goes into an error loop and just keeps popping up the second input error box.
if I enter a valid name in the second input box, then it will save it with that name, then continue to pop the box up.
If i ad the line that saves the file to the errhandler, then the user only has one chance to enter the name without invalid characters, otherwise he gets an error message and i have to go fix the original workbook.
Here is the code I'm using
Thank you,
Mike
I am getting an error on a line that just has resume on it after an errhandler
I have a workbook that I use to write invoices. Every time I open it, it adds 1 to the invoice number, saves the workbook, opens an input box that asks the user to enter the job name, then saves the workbook under a different name using the users input.
The problem is that some of our job names have an "/" in them, which causes an invalid file name.
To solve this I added an "on error" that would open another input box that states all the invalid characters and then asks the user to re-enter the job name then resumes on the line that saves the file.
when I do this I get an error on the resume and it either gives me an error or goes into an error loop and just keeps popping up the second input error box.
if I enter a valid name in the second input box, then it will save it with that name, then continue to pop the box up.
If i ad the line that saves the file to the errhandler, then the user only has one chance to enter the name without invalid characters, otherwise he gets an error message and i have to go fix the original workbook.
Here is the code I'm using
Code:
Private Sub Workbook_Open()
On Error GoTo errhandler:
If Range("I1").Value = "" Then
Names("jobNumber").Value = Evaluate(Names("jobnumber").Value) + 1
ThisWorkbook.Save
Application.ScreenUpdating = False
Dim strName As String
strName = InputBox("Please Enter Job Name")
ActiveWorkbook.SaveAs "C:\Users\Michael Guenter\Documents\Invoices\" & strName & " Invoice" & " " & Range("g6").Value & ".xls"
On Error GoTo 0
Range("b15").Value = strName
ActiveWorkbook.RefreshAll
Range("g5").Copy
Range("g5").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Range("I1").FormulaR1C1 = "x"
Range("b16").Copy
Range("b16").Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True
End If
Range("b13").Select
errhandler:
strName = InputBox("Job Name Cannot Contain \ / : * ? """" < >")
Resume
End Sub
Mike