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

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
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,214,649
Messages
6,120,730
Members
448,987
Latest member
marion_davis

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