ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
Morning all,
I have a code which works well & saves as a Word doc
I would like some advice on having save as a pdf please.
I have recorded a macro of saving a pdf but unsure what i need to remove from the existing code to apply the pdf save option.
Both codes supplied below if you could assist.
Many thanks.
Current save as Word code
Recorded Macro or you could advise otherwise.
I have a code which works well & saves as a Word doc
I would like some advice on having save as a pdf please.
I have recorded a macro of saving a pdf but unsure what i need to remove from the existing code to apply the pdf save option.
Both codes supplied below if you could assist.
Many thanks.
Current save as Word code
Code:
Private Sub Clear_Invoice_After_Printing_Click() Dim objWord As New Word.Application
'Copy the range Which you want to paste in a New Word Document as a screenshot
Dim strFileName As String
strFileName = "C:\Users\Ian\Desktop\REMOTES ETC\DR COPY INVOICES\" & Range("N4").Value & ".doc"
Range("G3:O60").CopyPicture xlPrinter
If Dir(strFileName) <> vbNullString Then
MsgBox "INVOICE " & Range("N4").Value & " WAS NOT SAVED AS IT ALLREADY EXISTS", vbCritical + vbOKOnly
Else
'Code here to save new file
With objWord
With .Documents.Add
.Parent.Selection.Paste
.SaveAs strFileName
.Close
End With
'.Visible = True
.Quit
End With
MsgBox "INVOICE " & Range("N4").Value & " WAS SAVED SUCCESSFULLY", vbInformation + vbOKOnly
Range("G13:I18").ClearContents
Range("N14:O18").ClearContents
Range("G27:N42").ClearContents
Range("G13:I13").ClearContents
Range("G45:I49").ClearContents
Range("N14:O16").ClearContents
Range("L18:O18").ClearContents
Range("G27:N42").ClearContents
Range("N4").Value = Range("N4").Value + 1
Worksheets("INV2").Range("N4").Value = Range("N4").Value
Range("G13").Select
ActiveWorkbook.Save
End If
End Sub
Recorded Macro or you could advise otherwise.
Code:
Sub PDFTEST1()
'
' PDFTEST1 Macro
'
'
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\Ian\Desktop\DR.pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
True
End Sub