PDA

View Full Version : Need he;p with code error, .SaveAs



VBE313
03-27-2019, 07:34 AM
The bold and underlined line is the error I am getting. Run-time error '1004' Method 'SaveAs' ofobject'_Workbook' failed

Dim path1 As String
Dim Filename1 As String
Dim filestring As String
filestring = path1 & Filename1

Application.ScreenUpdating = False
path1 = ActiveSheet.Range("I7").Text
Range("A1:f40").Select
Selection.Copy
Sheets("Laser").Select
Sheets.Add After:=ActiveSheet
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
ActiveSheet.Select
ActiveSheet.Move
Filename1 = Range("B4").Text
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=filestring & ".xlsx", FileFormat:=xlOpenXMLWorkbook
Application.DisplayAlerts = True
ActiveWorkbook.Close
Application.ScreenUpdating = True
Sheets("Laser").Select

End Sub

Kenneth Hobs
03-27-2019, 10:14 AM
Welcome to the forum! Please paste code between code tags. Click the # icon on reply toolbar to insert the tags.

You set the value before filling the values for the variables it uses.

filestring = path1 & Filename1