473,569 Members | 2,692 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I set path and name of report printed to virtual printer?

26 New Member
Hi,

I've installed a virtual printer that allows me to save access reports as .pdf files. Within Access (using VBA) I'm using the DoCmd.OpenRepor t action to send the file to be printed. When I do this a pop up box appears asking me for the path and name of the file to be saved.

Since I'm trying to automate this process, how do I set these parameters programatically in VBA?

Below is an excerpt of the code I have so far.

Expand|Select|Wrap|Line Numbers
  1. Function CutReports()
  2. Dim rsContacts As New ADODB.Recordset
  3. Dim RPTPAN As Access.Report
  4. Dim strName As String
  5.  
  6. rsContacts.ActiveConnection = CurrentProject.Connection
  7. rsContacts.Open "QRY12MoReviewNewMIPNo"
  8.  
  9. Do While Not rsContacts.EOF
  10.  
  11. 'Send data for this active record to Report and save as PAN.pdf
  12. strName = rsContacts!EEFullName 
  13. DoCmd.OpenReport "RPTPAN", acViewNormal, , "[EEFullName] = '" & strName & "'"
  14. ‘Here is where I’m stuck.  I need to dictate where and under what name to save the file.
  15.  
  16. DoCmd.Close acReport, "RPTPAN", acSaveNo
  17.  
  18.  
  19. 'Move to the next person in the recordset
  20. rsContacts.MoveNext
  21.  
  22. Loop
  23.  
Apr 20 '09 #1
4 2219
DonRayner
489 Recognized Expert Contributor
You could try the SendKeys function. I don't use it myself but I played with it a bit and this is how I got it to work. I had to use the forms timer to delay the sendkey function to give the save dialog enough time to open.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "RPTPAN", acViewNormal, , "[EEFullName] = '" & strName & "'"
  2. Me.TimerInterval = 500
  3.  
  4. Private Sub Form_Timer()
  5. SendKeys "DocumentName.pdf" & "{enter}", True
  6. Me.TimerInterval = 0
  7. End Sub
  8.  
Apr 20 '09 #2
NeoPa
32,564 Recognized Expert Moderator MVP
Ingenious solution Don :)

The simple answer is that there is no programmatic access to it as such. As far as Access (therefore your code) is aware, it is sending a report to a printer. The PDF builder part of the driver you're sending it to is entirely non-standard.

Having said that, it is possible that the provider of the software has released a separate API that you could use to control it directly. This depends on who the provider is of course. It may be worth a look (Google, or contact them directly).

Good luck with your project.
Apr 21 '09 #3
raddrummer
26 New Member
Will do. Thanks to all for checking it out.
Apr 21 '09 #4
NeoPa
32,564 Recognized Expert Moderator MVP
No worries.

Good luck with your project :)
Apr 21 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5742
by: Mohan | last post by:
Hi All, I am using web browser control in a VB 6.0 client server application to print reports. I am writing the report into a HTML file and displays the report to the user using the code, webbrowsercontrol.navigate2 "path of the html file" method. When the user clicks command button on the VB form to print the report I am using the...
1
2367
by: hawk | last post by:
I am creating a series of custom reports, whose parameters are specified through combo boxes in a form, which then generates a custom report based on a series of calculation queries. My problem is this...at the top of the report I've inserted several text boxes which link to the combo boxes on the entry form, and are supposed to show which...
2
4585
by: Wolfgang | last post by:
Hi, I need to timestamp printed records with the printing date. According to the customer's requests the report must be opened in preview-mode and the user clicks on the printer button if he really want to have a hardcopy. The customer selects the records with a special selection form, where he can combine up to appr. 20 different...
0
985
by: Chuck Van Den Corput | last post by:
I had posted the following question earlier under, what I believe now to be, a misleading subject line. Let me try again. I have an A97 report with numerous sub-reports that can be viewed in preview mode without any problem. However, when users print this report (in a network environment), the report doesn't make it from Access to the...
2
2763
by: Jelena B | last post by:
Bitmap that I put on my Crystal Report is printed in very bad resolution; it is completely rastered, and it is very hard to read letters on it. Printer settings are: Quality Settings: Draft Print Quality 300 x 300 dots per inch. The problem is that the same bitmap, on the same printer and same
6
4751
by: MLH | last post by:
I am unsure how to do this. I want this tray to be used for certain print jobs - jobs that will prompt me to load the bypass tray with sheet labels. How to force this? Dunno. Its the HP LaserJet 4200.
1
3342
by: adolph | last post by:
I have a problem with pages being printed out of order. An example is a 15 page duplexed report. Title page fine back of title page blank. (As it should be) SEcond page front, bottom says Page 1 of 15. Second page back says Page 10 of 15. Third page front says Page 3 of 15. Third page back says Page 4 of 15. Special not Page 10 of 15 is...
1
6489
by: Ron | last post by:
Hi All, I'm using A2K and need to print a specific pre-printed form. I know that once I have that report on a particular computer screen I can select "Page Setup" and change the margins to get the different fields I'm printing where I need them to print (fine tuning type of changes as all the controls are basically printing where...
6
2595
by: prakashwadhwani | last post by:
While making Vouchers in a form, I have a POST button which validates & posts the transaction to the main Accounts File. I also have a PRINT button which provides the user with a preview of the "to be printed" Voucher & then prints it onto paper. When the user clicks PRINT ... my code validates the voucher & prints it. Now I have to POST...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7970
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.