Dear All,
Using VBA code as given below, I get an error message (error 1004, Method SaveAs of object_Workbook failed) while saving the second worksheet (marked with *** behind the code line).
It seems it has to do with saving twice in a row from the same Workbook.
At least that is what I have read on the MS site.
Any idea how to solve this or how to make a workaround?
Any help is appreciated.
Regards from The Netherlands
VBA Code START
Sub Save()
Sheets("Data").Select
locatie1 = (Range("O3").Value)
'locatie1=C:\Uren\Reguliere uren
Sheets("Import 1").Select
Application.DisplayAlerts = False
ActiveSheet.Copy
Columns(1).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
ActiveWorkbook.SaveAs locatie1, xlTextWindows
ActiveWorkbook.Close
Application.DisplayAlerts = True
Sheets("Data").Select
locatie2 = (Range("O4").Value)
'locatie2 = "C:\Uren\Reguliere uren\Reguliere uren "&Gegevens!E1&"-"&Gegevens!C1&".txt"
Sheets("Gegevens").Select
Application.DisplayAlerts = False
ActiveSheet.Copy
Columns(1).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
ActiveWorkbook.SaveAs locatie2, xlTextWindows ***
ActiveWorkbook.Close
Application.DisplayAlerts = True
Sheets("Import 1").Select
Range("A1").Select
End Sub
VBA Code END
Using VBA code as given below, I get an error message (error 1004, Method SaveAs of object_Workbook failed) while saving the second worksheet (marked with *** behind the code line).
It seems it has to do with saving twice in a row from the same Workbook.
At least that is what I have read on the MS site.
Any idea how to solve this or how to make a workaround?
Any help is appreciated.
Regards from The Netherlands
VBA Code START
Sub Save()
Sheets("Data").Select
locatie1 = (Range("O3").Value)
'locatie1=C:\Uren\Reguliere uren
Sheets("Import 1").Select
Application.DisplayAlerts = False
ActiveSheet.Copy
Columns(1).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
ActiveWorkbook.SaveAs locatie1, xlTextWindows
ActiveWorkbook.Close
Application.DisplayAlerts = True
Sheets("Data").Select
locatie2 = (Range("O4").Value)
'locatie2 = "C:\Uren\Reguliere uren\Reguliere uren "&Gegevens!E1&"-"&Gegevens!C1&".txt"
Sheets("Gegevens").Select
Application.DisplayAlerts = False
ActiveSheet.Copy
Columns(1).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
ActiveWorkbook.SaveAs locatie2, xlTextWindows ***
ActiveWorkbook.Close
Application.DisplayAlerts = True
Sheets("Import 1").Select
Range("A1").Select
End Sub
VBA Code END