Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2013
    Posts
    82

    Unanswered: Save Current Worksheet as pdf

    I have the following code which saves the current worksheet and starts a new invoice with cleared contents.

    I want the 'Save As' to be in PDF format. How can I alter this?

    ******************************

    Sub NextInvoice()
    Range("I2").Value = Range("I2").Value + 1
    Range("I4:I6").ClearContents
    Range("B17:I22").ClearContents
    Range("B25:H39").ClearContents
    Range("C5151").ClearContents
    Range("H9:I14").ClearContents
    Range("H51").ClearContents
    End Sub

    Sub SaveInvoiceWithName()
    Dim NewFN As Variant
    'Copy Invoice to a new workbook
    ActiveSheet.Copy
    NewFN = "U:\Old User Files\REPAIR STATION\RPO Invoices\Repair Orders\RPO#" & Range("I2").Value & ".xlsx"
    ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
    ActiveWorkbook.Close
    NextInvoice
    End Sub

    *******************************************

    Thanks for the help.

  2. #2
    Join Date
    Oct 2003
    Location
    London
    Posts
    341
    I have a similar routine. I don't copy to a workbook though and just save directly from the active sheet but I save a range rather than the active sheet.

    Code:
    Sub SaveInvoiceWithName()
    
    Dim NewFN As Variant
    
    NewFN = "U:\Old User Files\REPAIR STATION\RPO Invoices\Repair Orders\RPO#" & Range("I2").Value & ".pdf"
    
    Sheets("Sheet1").Range("A1:H51").ExportAsFixedFormat Type:=xlTypePDF, Filename:= NewFN, Quality:= xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
    
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •