How to export only page 1 as PDF

Melimob

Active Member
Joined
Oct 16, 2011
Messages
396
Office Version
  1. 365
Hi there

I have the below code which works perfectly however I want to only export/save page 1 of the PDF not page 2.
Can anyone please tell me how I can incorporate this in to the below code?:

Code:
Sub emailsavePDF_weekly()


Dim objOutlook As Object
    Dim objMail As Object
    Dim signature As String
    Dim oWB As Workbook
    Set oWB = ActiveWorkbook
    Dim PDF_File As String
    
    
    
     s = Range("b1").Value
  
  
 '
     ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
         s, Quality:=xlQualityStandard, IncludeDocProperties _
         :=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
         
         
    PDF_File = Range("b1").Value
 
    
    Set objOutlook = CreateObject("Outlook.Application")
    Set objMail = objOutlook.CreateItem(0)
        
    With objMail
        .display
    End With
        signature = objMail.body
    With objMail
        .To = Range("A1").Value
        .Cc = "test@test.co.uk"
        .Subject = "Weekly League Tables for Banked vs Written " & Range("e8").Value
      
        .body = "Dear All" _
                      & vbNewLine & vbNewLine & _
                      "Please find attached this weeks' league tables." _
                      & vbNewLine & vbNewLine _
                      & "Any questions please do not hesitate to ask." _
                      & vbNewLine & vbNewLine _
                      & "Kind Regards," _
                      & vbNewLine _
                      & "Lindsay" _
                      & vbNewLine _
                      & signature
        .Attachments.Add PDF_File
        .Save
        .display
    End With
    '_




    Set objOutlook = Nothing
    Set objMail = Nothing
End Sub
 
Last edited:

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
.
This should do it :

Code:
Sheets("Sheet1").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
         s, Quality:=xlQualityStandard, IncludeDocProperties _
         :=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
 
Upvote 0
Hi,
Just use additional parameters From:=1, To:=1 as follows:
Rich (BB code):
  ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=s, _
         Quality:=xlQualityStandard, IncludeDocProperties:=True, _
         From:=1, To:=1, _
         IgnorePrintAreas:=False, OpenAfterPublish:=False
 
Upvote 0
Hi,
Just use additional parameters From:=1, To:=1 as follows:
Rich (BB code):
  ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=s, _
         Quality:=xlQualityStandard, IncludeDocProperties:=True, _
         From:=1, To:=1, _
         IgnorePrintAreas:=False, OpenAfterPublish:=False

Perfect thank you both for your replies.

KR
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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