VBA Save worksheet print area as pdf

tigerdel

New member
Joined
Aug 23, 2012
Messages
40
Reaction score
0
Points
0
Location
Cambridgeshire
Excel Version(s)
Office 365
Also posted at mrexcel.com with no response [https://www.mrexcel.com/board/threads/vba-save-as-pdf.1147479/]


I have the code below that should save an excel worksheet as a pdf file

However, at the line: .ExportAsFixedFormat Type:=xlTypePDF, FileName:=FullPath, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
I get this error:


1601832940003-png.23606



No document is Not Open

Code:
[I]Private Sub SaveQuotationAsPDF(cell As Range)
    Dim FileName As String, FullPath As String
        With ActiveSheet
            FileName = .Range("J7").Value & "-" & .Range("j8").Value
            FullPath = Environ$("OneDrive") & "\MJM Services\2.0 Quotations\pdf Copy" & FileName & ".pdf"

            .ExportAsFixedFormat Type:=xlTypePDF, FileName:=FullPath, Quality:=xlQualityStandard, _
                IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
        End With
        cell.Parent.Hyperlinks.Add cell, FullPath, TextToDisplay:="Open Quotation"
End Sub[/I]

Any idea what I've done wrong here

Thanks for your time


 
Was this solved?

Hi. I am just wondering if you ever had a solution to this problem? I seem to be having a similar issue.
Thanks.



Also posted at mrexcel.com with no response [https://www.mrexcel.com/board/threads/vba-save-as-pdf.1147479/]


I have the code below that should save an excel worksheet as a pdf file

However, at the line: .ExportAsFixedFormat Type:=xlTypePDF, FileName:=FullPath, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
I get this error:


1601832940003-png.23606



No document is Not Open

Code:
[I]Private Sub SaveQuotationAsPDF(cell As Range)
    Dim FileName As String, FullPath As String
        With ActiveSheet
            FileName = .Range("J7").Value & "-" & .Range("j8").Value
            FullPath = Environ$("OneDrive") & "\MJM Services\2.0 Quotations\pdf Copy" & FileName & ".pdf"

            .ExportAsFixedFormat Type:=xlTypePDF, FileName:=FullPath, Quality:=xlQualityStandard, _
                IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
        End With
        cell.Parent.Hyperlinks.Add cell, FullPath, TextToDisplay:="Open Quotation"
End Sub[/I]

Any idea what I've done wrong here

Thanks for your time


 
Back
Top