Saving as PDF ? ANyone know why this code is saving as a PDF ?

JamesStag

New Member
Joined
Jul 25, 2018
Messages
18
Code:
Sub saveworkbook()

Sheets("Details").Select
 ActiveSheet.ExportAsFixedFormat Type:=xlsm, _
        filename:="C:\Users\James\Documents\Excel Test Folder\Quotes Invoices Spread Sheets\_" & _
        Worksheets("Details").Range("C6").Value & ".xlsm", _
        OpenAfterPublish:=False

End Sub
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
You haven't declared/defined the variable xlsm so VBA will have given a default initial value.

That value could be 0 and if that's the case it corresponds to the value for the XlFixedFormatType constant xlTypePDF.
 
Upvote 0
The type is xlTypePDF or xlTypeXPS.

Try:
Code:
  Sheet1.SaveAs "C:\Users\James\Documents\Excel Test Folder\" & _
    "Quotes Invoices Spread Sheets\_" & _
    Worksheets("Details").Range("C6").Value & ".xlsm", _
    xlOpenXMLWorkbookMacroEnabled
 
Upvote 0

Forum statistics

Threads
1,215,572
Messages
6,125,605
Members
449,238
Latest member
wcbyers

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