save as pdf file problem (1 Viewer)

Eljefegeneo

Still trying to learn
Local time
Today, 06:46
Joined
Jan 10, 2011
Messages
904
PDF file problem
I have some code that does two things. It sends a copy of a report via email as a pdf flie and (2) then saves the same report as a pdf file to a folder. Unfortunately I cannot figure out how not to have the pdf file open. The DB is on several different computers and the Adobe Reader always seems to open up, sometimes placing the pdf file in the forefront so the user has to find the email program, send the email, and close the pdf file. .
The main problem seems to be that when saving the report as a pdf file, it automatically opens up the pdf file using Adobe Reader after the save. While this would seem to be an Adobe problem, searching for the answer only produces "help" that probably only an advanced programmer might understand. So, I thought perhaps there is some VBA code that would close the pdf file or prevent it from opening.
I first open the report with the following:
DoCmd.OpenReport "rptContractClient", acViewReport, , "[SequenceNumber] = " & Me![SequenceNumber], , "A"
Then I save the report with:
DoCmd.OutputTo acOutputReport, MyRpt, acFormatPDF, MyPath & MyFileName, True
Finally I send it via email using:
DoCmd.SendObject acSendReport, "rptContractClient", acFormatPDF, Forms!frmContracts.Email, Nz(Forms!frmContracts.ECC, ""), Nz(Forms!frmContracts.EBCC, ""), "Contract for" & " " & [AltStationName], Format(Date, "Long Date") & Chr(10) & MsgSt
Individually the above codes function fine. But the darn pdf file always opens and I have to manually close it. Not a big problem if only one record is being saved and sent, but if I want to do it with for many reports at the same time using some loop type code, it would result in too many pdf files open.
So, can I execute the save without opening the pdf file, or is there a fairly simple way of closing the pdf file with vba?
 

Mihail

Registered User.
Local time
Today, 16:46
Joined
Jan 22, 2011
Messages
2,373
Have you tried ?
I can't try this but I don't see any reason to open the report before.
 

Eljefegeneo

Still trying to learn
Local time
Today, 06:46
Joined
Jan 10, 2011
Messages
904
Thanks. I tried it and the pdf file still opened. Any other suggestions. And without confusing the issue, I need to be able to pass filter ( Id = Me.Id) and the OpenArg: the "A" at the end of the open report. Otherwise I would open all reports based on the form data. But let's solve the problem of the opening of the PDF file on save as pdf file VBA.
 

Eljefegeneo

Still trying to learn
Local time
Today, 06:46
Joined
Jan 10, 2011
Messages
904
Sometimes the easiest things are the most difficult. I changed one work an volia! It works.

DoCmd.OutputTo acOutputReport, MyRpt, acFormatPDF, MyPath & MyFileName, False (Not True).

Guess I copied some code off a forum without understanding what the condition of True or False meant.

thanks for your time. I do appreciate it.
 

Users who are viewing this thread

Top Bottom