VBA creates PDF file with worksheet name

asyamonique

Well-known Member
Joined
Jan 29, 2008
Messages
1,280
Office Version
  1. 2013
Platform
  1. Windows
Good Day,
Is it possible to create that PDF file with related worksheet name only?
Many Thanks

VBA Code:
Sub Button1_Click()
On Error Resume Next
   ChDir "\\172.16.23.181\xxxx\xxxxx"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        "\\172.16.23.181\folder\xxxxx\xxxxx.pdf", Quality:= _
        xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
        OpenAfterPublish:=True
End Sub
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hi There

Maybe try...

VBA Code:
Sub Button1_Click()
Dim wsA     As Worksheet
Dim strFile, myfile As String
On Error Resume Next
wsA.Activate
    strFile = "\\172.16.23.181\folder\xxxxx\xxxxx\" & wsA.Name & ".pdf"
    myfile = strFile
ActiveSheet.ExportAsFixedFormat _
                        Type:=xlTypePDF, _
                        Filename:=myfile, _
                        Quality:=xlQualityStandard, _
                        IncludeDocProperties:=True, _
                        IgnorePrintAreas:=False, _
                        OpenAfterPublish:=True
End Sub
 
Upvote 0
Hi There

Maybe try...

VBA Code:
Sub Button1_Click()
Dim wsA     As Worksheet
Dim strFile, myfile As String
On Error Resume Next
wsA.Activate
    strFile = "\\172.16.23.181\folder\xxxxx\xxxxx\" & wsA.Name & ".pdf"
    myfile = strFile
ActiveSheet.ExportAsFixedFormat _
                        Type:=xlTypePDF, _
                        Filename:=myfile, _
                        Quality:=xlQualityStandard, _
                        IncludeDocProperties:=True, _
                        IgnorePrintAreas:=False, _
                        OpenAfterPublish:=True
End Sub
Hello,
Thanks for the reply, that code creates PDF file as in worbook name not the related worksheet name.
Thanks
 
Upvote 0
Hello,
Thanks for the reply, that code creates PDF file as in worbook name not the related worksheet name.
Thanks

Try amended below:

VBA Code:
Sub Button1_Click()
Dim wsA     As Worksheet
Dim strFile, myfile As String
On Error Resume Next
wsA.Activate
    strFile = "\\172.16.23.181\folder\xxxxx\xxxxx\"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
strFile & "" & ActiveSheet.Name, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=True
End Sub
 
Upvote 0
Try amended below:

VBA Code:
Sub Button1_Click()
Dim wsA     As Worksheet
Dim strFile, myfile As String
On Error Resume Next
wsA.Activate
    strFile = "\\172.16.23.181\folder\xxxxx\xxxxx\"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
strFile & "" & ActiveSheet.Name, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=True
End Sub
Many thanks, thats great.
 
Upvote 0
Pleasure to assist and thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,222
Messages
6,123,706
Members
449,118
Latest member
MichealRed

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