
シートの内容をPDFファイルとして
出力できます!
VBAコード
ここでは例として、
・シート「sample」の内容を
・PDFファイルとしてデスクトップ上に出力
します。

Option Explicit
Sub sample()
Dim pdfFilePath As String
Dim fso As Object
'PDFファイルのパスを指定
pdfFilePath = "C:\Users\user\Desktop\サンプル.pdf"
Set fso = CreateObject("Scripting.FileSystemObject")
'PDFファイルが存在したら削除(読み取り専用でも削除)
If fso.FileExists(pdfFilePath) Then
fso.deleteFile pdfFilePath, True
End If
'PDFファイルを出力
Worksheets("sample").ExportAsFixedFormat Type:=xlTypePDF, Filename:=pdfFilePath
'後片付け
Set fso = Nothing
End Sub
実行結果
シートの内容をPDFファイルとして出力できました。


参考
上記のコードで使用した以下の詳細は、公式サイトをご確認ください。
●「Worksheetオブジェクト」の「ExportAsFixedFormat」メソッド