Print to PDF Macro, or possibly more

Cliffork

New Member
Joined
Feb 12, 2020
Messages
43
Office Version
  1. 365
I have a compilation file that we fill in calibration forms for a device on. There are a handful of sheets in the workbook, but every since one has a sheet named "Cal Form" that I am trying to automate printing a PDF of, with the name being pulled from two cells in said sheet (C8 and K8).

If possible I'm also trying to find some way to print PDF's of dozens of existing Cal Forms as my customers request them all the time, and getting them is tedious. I'm not sure what the best way to do this would be.
I have hundreds of these files and it would honestly be convenient to just be able to print every single one to PDF automatically somehow.

I've tried searching the forums and just googling but it seems everyone is trying to do something differently and I've tried 2 so far with no luck on my end. I've also tried recording a macro of saving it as a PDF but it doesn't appear to function.

Code for my recorded macro that doesn't seem to work is
VBA Code:
Sub PrintToPDF()
'
' PrintToPDF Macro
'
' Keyboard Shortcut: Ctrl+q
'
    ChDir "Z:\Shared\EEW\Lab\Cal Cert PDF"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        "Z:\Shared\EEW\Lab\Compilation Documents\Envision\Meter Repair Compilation File -Template.pdf" _
        , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
        :=False, OpenAfterPublish:=False
End Sub


Sheet is below in case it helps.

Meter Repair Compilation File -TemplateTEST.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAE
2Testing and Calibration Report
3
4
7
8Date:10/29/2024Meter SN#: 1234567BModel #:ENV200RMA#:0500-1234
9Lab Testing Performed
10 Bluetooth Battery Charger Available Pressure CH4 Sensor H2S Sensor
11 Firmware Battery health Impact Pressure CO2 Sensor CO Sensor
12 Thermistor Static Pressure Seal Integrity O2 Sensor H2 Sensor
13
14Calibration Results:
15GasTarget Value 1Analyzer Value 1Target Value 2Analyzer Value 2Calibration Gas Bottle Lot#Analytical Uncertainty
16A20.9% O220.9% O20.00--32-401209938-1± 0.02% abs
17B11% O211% O20.00--32-401919744-1± 0.02% abs
18C50% CH435% CO250% CH40.0035% CO20.00141-403023316-1± 0.02% abs
19D15% CH415% CO215% CH40.0015% CO20.00141-402762057-1± 2% rel
20E40% CH460% CO240% CH40.0060% CO20.00141-403007833-1± 1% rel
21F100% CO2--100% CO20.0025-401897982-1- 0.01% abs
22G100% CH4100% CH40.00--141-402357134-1- 0.5% abs
27
28Zero Gas ValueCH4CO2O2H2H2SCO
29L99.999% N20.000.000.000.000.000.00
30Calibration Gas directly traceable to NIST ASTM Class 1 weights and/or NIST gas mixture reference materials
31Pressure Sensors: (All measurements made in"WC)
32Low PressuresHigh Pressures
33SensorTarget Value 1Analyzer Value 1Target Value 2Analyzer Value 2SensorTarget Value 1Analyzer Value 1Target Value 2Analyzer Value 2
34Applied0.0000.00-4.500.00Available0.0000.00-100.000.00
35Diff.0.0000.0004.5000.000Diff.0.0000.0020.0000.00
36Applied0.0000.000-100.000.000
37This device has passed testing and calibration procedures as specified by Elkins Earthworks, LLC.
38
39Calibrated by (Signature):KC
40
41At Elkins Earthworks we appreciate your business. We strive for a standard 10 working day turn arround on all calibrations and repairs from the time we have received your instrument. Your instrument has been serviced in 32559 days. We hope you appreciate our dedication to service and quality.
42
43
44Thanks,Notes as to why service exceeded 10 day turn
45
46
47
48
49President
50Elkins Earthworks, LLC.
51
52
53
54
Cal Form
Cell Formulas
RangeFormula
K8K8=('Customer Info'!B15)
R8R8='Customer Info'!B16
Y8Y8=('Customer Info'!B13)
B10B10=IF(ISNUMBER(SEARCH("X",'Final Insp.'!A13)),"P", "")
B11B11=IF(ISNUMBER(SEARCH("X",'Final Insp.'!A11)),"P", "")
B12B12=IF(ISNUMBER(SEARCH("X",'Final Insp.'!A68)),"P", "")
H10H10=IF(ISNUMBER(SEARCH("X",'Final Insp.'!A10)),"P", "")
H11H11=IF(ISNUMBER(SEARCH("",'Final Insp.'!A28)),"P", "")
H12H12=IF(ISNUMBER(SEARCH("",'Final Insp.'!A28)),"P", "")
N10N10=IF(ISNUMBER(SEARCH("",'Final Insp.'!A28)),"P", "")
N11N11=IF(ISNUMBER(SEARCH("",'Final Insp.'!A28)),"P", "")
N12N12=IF(ISNUMBER(SEARCH("X",'Final Insp.'!A52)),"P", "")
V10V10=IF(ISNUMBER(SEARCH("",'Final Insp.'!A53)),"P", "")
V11V11=IF(ISNUMBER(SEARCH("",'Final Insp.'!A53)),"P", "")
V12V12=IF(ISNUMBER(SEARCH("",'Final Insp.'!A53)),"P", "")
AA10AA10=IF(ISNUMBER(SEARCH("",'Final Insp.'!A53)),"P", "")
AA11AA11=IF(ISNUMBER(SEARCH("",'Final Insp.'!A53)),"P", "")
AA12AA12=IF(ISNUMBER(SEARCH("",'Final Insp.'!A53)),"P", "")
K16K16='Final Insp.'!F35
K17K17='Final Insp.'!F42
K18:K20,K22K18='Final Insp.'!D37
Q18:Q21Q18='Final Insp.'!E37
H29H29='Final Insp.'!D36
L29L29='Final Insp.'!E36
P29P29='Final Insp.'!F36
T29T29='Final Insp.'!D47
X29X29='Final Insp.'!F48
AB29AB29='Final Insp.'!E46
G34:G35G34='Final Insp.'!D25
M34:M35M34='Final Insp.'!I25
W34W34='Final Insp.'!E24
W35W35='Final Insp.'!E26
W36W36='Final Insp.'!E25
AC34AC34='Final Insp.'!J24
AC35AC35='Final Insp.'!J26
AC36AC36='Final Insp.'!J25
A41A41="At Elkins Earthworks we appreciate your business. We strive for a standard 10 working day turn arround on all calibrations and repairs from the time we have received your instrument. Your instrument has been serviced in " & NETWORKDAYS('Customer Info'!B14,C8,'Drop Down lists'!M2:M105)-1 & " days. We hope you appreciate our dedication to service and quality."
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AA10:AA12Expression=RIGHT(UPPER('Customer Info'!$B$15),1)="D"textNO
T28:AE29Expression=RIGHT(UPPER('Customer Info'!$B$15),1)="D"textNO
T28:AE28Expression=RIGHT(UPPER('Customer Info'!$B$15),1)="D"textNO
AA10:AE12,T28:AE29Expression=RIGHT(UPPER('Customer Info'!$B$15),1)="D"textNO
I39Cellcontains a blank value textNO
C8Cellcontains a blank value textNO
Cells with Data Validation
CellAllowCriteria
I39:Z39List='Drop Down lists'!$A$1:$A$6
 
I don't get the Save As window so I can't reproduce that problem. You have a link to another file in each of the two workbooks. In the Data menu at the top, click on Workbook Links, break the link and save the file and close it. You have to do this for each file. Then try the macro again.
Looks to have been all it is, unfortunate because that's probably on every file I have, I don't even know why its linking to it, but I'm sure I made some mistake 2-3 years ago when I added that tab for a specific test. Thank you though! You have been incredibly helpful!
 
Upvote 0

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,224,813
Messages
6,181,112
Members
453,021
Latest member
Justyna P

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