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
 

Some videos you may like

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,218
Office Version
  1. 365
Platform
  1. Windows
What's the error message?
 

leewoo5

New Member
Joined
Feb 5, 2017
Messages
13
'Run time error: 1004'

A specified dimension is not valid for current chart type.
 
Last edited:

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,218
Office Version
  1. 365
Platform
  1. Windows
Are any of the sheets you are trying to save chart sheets or sheets that contain charts?
 

Watch MrExcel Video

Forum statistics

Threads
1,122,519
Messages
5,596,634
Members
414,082
Latest member
sasmita

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
Top