Macro that exports PDF files to V Drive

matthewR
5StarLounger
Posts: 627
Joined: 03 Feb 2010, 15:02

Macro that exports PDF files to V Drive

Post by matthewR »

I have a macro on a form that exports PDF files to a Network Drive. I used to just click on the button on the form and it used to create 13 pdf files on the V drive. Now instead of creating and exporting each PDF file, it gives me a message saying: The document was previously formatted for the printer \\hpg3328\PRT04361, but that printer isn't available. Do you want to use the default printer \\HMPGPRTP12\PRT04350. This message appears after each of the pdf files and I have to click ok each time instead of it just running without intervention. Is there anyway to get rid of this message?

This is the macro:
Private Sub CmdExport_Click()
Dim zDestFolder As String
Dim zReportName(1 To 13) As String
Dim iCntr As Integer

zReportName(1) = "01_Total All Members ReportAll"
zReportName(2) = "01_Total All Members ReportOPEB"
zReportName(3) = "01_Total All Members ReportNON_OPEB"
zReportName(4) = "01_Total All Members ReportPre65"
zReportName(5) = "01_Total All Members ReportExcludesPre65"
zReportName(6) = "01_Total All Members ReportPre65andOPEB"
zReportName(7) = "01_Total All Members ReportExcludesPre65_OPEB"
zReportName(8) = "01_Total All Members ReportPre65andNONOPEB"
zReportName(9) = "01_Total All Members ReportExcludesPre65_NONOPEB"
zReportName(10) = "03RPt_CntbyProduct_CompPPO2"
zReportName(11) = "03RPt_CntbyProduct_BlueCare2"
zReportName(12) = "03RPt_FirstStBasicandCDHGold"
zReportName(13) = "03RPt_Medicfill and POS"

zDestFolder = "V:\CORPDATA17\Admin\Linda\DelawareReportPDFFolder\"

' Try to delete pdfs if they exist
On Error Resume Next
For iCntr = 1 To UBound(zReportName)
Kill zDestFolder & zReportName(iCntr) & ".pdf"
Next iCntr
On Error GoTo 0

For iCntr = 1 To UBound(zReportName)
DoCmd.OpenReport zReportName(iCntr), acViewPreview
DoCmd.OutputTo acOutputReport, zReportName(iCntr), acFormatPDF, _
zDestFolder & zReportName(iCntr) & ".pdf"
DoCmd.Close acReport, zReportName(iCntr), acSaveNo
Next iCntr

End Sub

User avatar
HansV
Administrator
Posts: 78241
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Macro that exports PDF files to V Drive

Post by HansV »

Open the report "01_Total All Members ReportAll" in design view.
On the Page Setup tab of the ribbon, click Page Setup.
Activate the Page tab of the Page Setup dialog.
You'll probably find that "Use a specific printer" is selected. Select "Default printer" instead.
S0138.png
Click OK, then close and save the report.

Repeat for each of the other 12 reports.
You shouldn't get the warning any more.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

matthewR
5StarLounger
Posts: 627
Joined: 03 Feb 2010, 15:02

Re: Macro that exports PDF files to V Drive

Post by matthewR »

Thank you so much Hans. I want you to know that I am retiring at the end of this month so you won't be getting anymore frantic questions from me. You have been a tremendous help through the years and I don't think I would have gotten this far without you. Thank you. I may slip a question or two in from home.

User avatar
HansV
Administrator
Posts: 78241
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Macro that exports PDF files to V Drive

Post by HansV »

It's been a pleasure. Enjoy your retirement!
Best wishes,
Hans