Hello Experts,
There is an Run-time error '2147024773 (8007007b) Document not saved while trying to export excel as PDF. Please help me resolve this problem. Attaching code below.
Code
- Sub SaveasPDF()
- Dim filepath As Variant, str As String
- 'Assigning name of the file in the format "customer"
- str = Form_New_Invoice1.TxtB_BillToName
- 'assigning path
- filepath = "E:\MS Excel\Invoices\" & str & ".pdf"
- Sheet2.ExportAsFixedFormat Type:=xlTypePDF, fileName:=filepath, Quality:=xlQualityStandard, includedocproperties:=True, _
- OpenAfterPublish:=True
- End Sub