Change from Save As Excel file to Save As PDF

cookeetree

Board Regular
Joined
Mar 2, 2015
Messages
52
G'day Excel Gods,

Could you please assist with changing the below VBA to saving the file as a PDF?
Currently, it hides the empty rows on the RP Concrete worksheet, prints it, then copies it to a new file, pastes the values of formulas and saves it (file name needs to be entered each time).
I just want to hide the empty rows on the RP Concrete worksheet, print it and save the worksheet as a PDF (file name needs to still be entered).

Any help you could provide would be greatly appreciated.
Cheer, Jason.



Sub Print_and_Save_Concrete_Report()

' Select and work within the correct file and sheet
With ThisWorkbook.Worksheets("RP Concrete")

' For each value in "Specimen number" column
For Each Cell In .Range("A16:A24")

' If the value is zero
If (Cell = 0) Then

' Hide the row
Cell.EntireRow.Hidden = True

End If

Next

' Print out the report
.Range("A1:AD35").PrintOut

' Save the report sheet

' Copy the sheet into a new excel workbook
.Copy

' Update the cells so they only contain values, not references
ActiveWorkbook.Worksheets(1).Range("E5:E9").Copy
ActiveWorkbook.Worksheets(1).Range("E5:E9").PasteSpecial xlPasteValues
ActiveWorkbook.Worksheets(1).Range("V7:V9").Copy
ActiveWorkbook.Worksheets(1).Range("V7:V9").PasteSpecial xlPasteValues
ActiveWorkbook.Worksheets(1).Range("A15:AA24").Copy
ActiveWorkbook.Worksheets(1).Range("A15:AA24").PasteSpecial xlPasteValues
ActiveWorkbook.Worksheets(1).Range("H30:H31").Copy
ActiveWorkbook.Worksheets(1).Range("H30:H31").PasteSpecial xlPasteValues
ActiveWorkbook.Worksheets(1).Range("N34").Copy
ActiveWorkbook.Worksheets(1).Range("N34").PasteSpecial xlPasteValues
ActiveWorkbook.Worksheets(1).Range("AA34").Copy
ActiveWorkbook.Worksheets(1).Range("AA34").PasteSpecial xlPasteValues
ActiveWorkbook.Worksheets(1).Range("D35").Copy
ActiveWorkbook.Worksheets(1).Range("D35").PasteSpecial xlPasteValues


' Save the file
Dim reportSaveFileName As String

' Get the filename to save as
reportSaveFileName = "False"
reportSaveFileName = Application.Dialogs(xlDialogSaveAs).Show("S:\Works and Infrastructure Services\Works and Operations\Works and Operations\Soil Lab\REPORTS\ConcreteReport " & Date, 52)

' If (reportSaveFileName = "False") Then
'
' 'MsgBox ("It was false")
' Else
'
' 'MsgBox ("Path: " & reportSaveFileName)
' 'ActiveWorkbook.SaveAs Filename:=reportSaveFileName, FileFormat:=52
'
' End If

' Clear the clipboard
Application.CutCopyMode = xlCopy

' Close the report sheet
ActiveWorkbook.Close Savechanges:=False

' Unhide the cells
For Each Cell In .Range("A15:A23")
Cell.EntireRow.Hidden = False
Range("A1").Select

Next

End With

End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Sub ExportAsFixedFormat(Type As XlFixedFormatType, [Filename], [Quality], [IncludeDocProperties], [IgnorePrintAreas], [From], [To], [OpenAfterPublish], [FixedFormatExtClassPtr], [WorkIdentity])
VBA Code:
ActiveWorkbook.ExportAsFixedFormat xlTypePDF, reportSaveFileName, , True
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,954
Members
449,095
Latest member
nmaske

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