View Single Post
 
Old 01-26-2016, 06:28 AM
D2A6G D2A6G is offline Windows 10 Office 2010 32bit
Novice
 
Join Date: Jan 2016
Posts: 1
D2A6G is on a distinguished road
Default Saving an Excel document to PDF - VBA

Hi,

Basically i am trying to save my excel sheet to a PDF by using a VBA. What i have tried doing is saving the document under my current sheet name (as i have multiple sheets), so i dont have to edit the PDF afterwards in terms of name.

This is what ive got so far

Sub PDF()

Dim strXLName As String, strPDFName As String, intPos As Integer

strXLName = ActiveSheet.Name
intPos = InStr(1, strXLName, ".")
strPDFName = Left(strXLName, intPos) & "pdf"

ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=strPDFName, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True

End Sub

But this does not save it as the sheet name like i want it too?, even just a certain cell it saves it as would be alright?, any ideas?
Reply With Quote