Save as PDF

MOORED

New Member
Joined
Sep 25, 2017
Messages
14
HI ,

any help would be most welcome:)

I have the following code which I link to a button that automatically saves a certain section of a worksheet. how can I modify the code to save a PDF rather than worksheet xls


Sub SaveShts()
Dim Ws As Worksheet, i As Integer
Application.ScreenUpdating = False
i = 0
For Each Ws In Worksheets
If Ws.Visible Then
i = i + 1
If i > 2 Then Exit For
Ws.Copy
ActiveWorkbook.SaveAs "C:\Users\User\Desktop\Invoice work" & Ws.Range("K1").Text, 51
ActiveWorkbook.Close
End If
Next Ws
End Sub


Kind regards
Darren
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Code:
sFile = "c:\folder\file.pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=  sFile,  Quality:=  xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False,   OpenAfterPublish:=True
 
Last edited:
Upvote 0
Many thanks Ranman,

Forgive me as I am just in early stages of learning

do I just need to add this section to the code obviously changing the destination
 
Upvote 0

Forum statistics

Threads
1,215,393
Messages
6,124,680
Members
449,180
Latest member
kfhw720

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