Consulting

Results 1 to 2 of 2

Thread: Need he;p with code error, .SaveAs

  1. #1
    VBAX Regular
    Joined
    Mar 2019
    Posts
    15
    Location

    Need he;p with code error, .SaveAs

    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

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •