I have a code that saves a copy of a workbook.
As part of a seperate routine this file is checked to see if it exists and if it does to reopen it.
However if I get an error stating that the file is not in recognisable format and do I want to open it?
How do I save it so it doesn't give this error?
I have added the Application.DisplayAlerts = False and the file is opened but then "Workbooks(invnum)" doesn't work - Subscript out of range
Code:
If globalchange = False Then Else
ActiveSheet.Copy
Application.DisplayAlerts = False
invnum = Replace$(invnum, Mid$("/", 1, 1), "-")
invnum = Replace$(invnum, Mid$("""", 1, 1), "")
ActiveWorkbook.SaveAs FileName:="\\ih-serv\company\Shipping\Invoices\Excel\" & invnum & ".xls"
Application.DisplayAlerts = True
ActiveWorkbook.Close
End If
As part of a seperate routine this file is checked to see if it exists and if it does to reopen it.
Code:
invnum = Sheets("input").Range("A1").Value
invnum = Replace$(invnum, Mid$("/", 1, 1), "-")
invnum = Replace$(invnum, Mid$("""", 1, 1), "")
If Fileexists("\\ih-serv\company\Shipping\Invoices\Excel\" & invnum & ".xls") = True Then
runnew = MsgBox("This invoice has already been generated" & vbCrLf & "Do you want to generate a new copy?", vbYesNo, "Warning")
If runnew = 7 Then
globalchange = False
Application.DisplayAlerts = False
Application.Workbooks.Open ("\\ih-serv\company\Shipping\Invoices\Excel\" & invnum & "*")
Application.DisplayAlerts = True
Workbooks(invnum).Sheets("invoice EDIT").Range("A1:W402").Copy Destination:=Workbooks("invoice").Sheets("invoice EDIT").Range("A1").Paste
Workbooks(invnum).Close
Else
newinvoice
End If
Else
newinvoice
End If
However if I get an error stating that the file is not in recognisable format and do I want to open it?
How do I save it so it doesn't give this error?
I have added the Application.DisplayAlerts = False and the file is opened but then "Workbooks(invnum)" doesn't work - Subscript out of range