Macro VBA Debug Error

leewoo5

New Member
Joined
Feb 5, 2017
Messages
13
Hi all,

I am getting a debug error with the red text below.
I am unsure why there is an issue with this, any ideas?

Many thanks,



Code:
Sub SaveAsClosed() 
  Dim fName As String
  Dim sLoc As String  'location
 
  sLoc = "I:\FST\Quality\Non-Conformance\Non-Conformance Reports\Open\Closed\"
 
  ' Select both sheets to export into PDF file
  Sheets(Array("NCR", "RCA")).Select
 
  With ActiveSheet
   
    fName = .Range("L4").Value & "C" & "-" & .Range("E6").Value
 
    'Save as xlsm
[COLOR=#ff0000]    ActiveWorkbook.SaveAs Filename:=sLoc & fName, FileFormat:=xlOpenXMLWorkbookMacroEnabled[/COLOR]
   
    ' Export to the PDF
    .ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
                         sLoc & fName, Quality:=xlQualityStandard, _
                         IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
   
    ' Unselect the group (select only one sheet)
    .Select
 
  End With
  
    sLoc = "I:\FST\Quality\Non-Conformance\Non-Conformance Reports\Customer Copy Non-Conformance Report\"
 
  ' Select both sheets to export into PDF file
  Sheets(Array("CUSTOMER COPY")).Select
 
  With ActiveSheet
   
    fName = .Range("L4").Value & "C" & "-" & .Range("E6").Value
 
    'Save as xlsm
    ActiveWorkbook.SaveAs Filename:=sLoc & fName, FileFormat:=xlOpenXMLWorkbookMacroEnabled
   
    ' Export to the PDF
    .ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
                         sLoc & fName, Quality:=xlQualityStandard, _
                         IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
   
    ' Unselect the group (select only one sheet)
    .Select
 
  End With
 
End Sub
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
'Run time error: 1004'

A specified dimension is not valid for current chart type.
 
Last edited:
Upvote 0
Are any of the sheets you are trying to save chart sheets or sheets that contain charts?
 
Upvote 0

Forum statistics

Threads
1,214,793
Messages
6,121,614
Members
449,039
Latest member
Mbone Mathonsi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top