473,386 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Printing to a printer or pdf file

waynetheengineer
Hi all,

I'm trying to set up two buttons on a form:
one to print a report to my printer (which happens to be set as default printer in windows) and,
another to convert the report to a pdf file (which is not set as default)

Is there a way to write code in the buttom click event to change which printer it prints to (either \\W1\HP Color LaserJet 1500 or Adobe PDF)?

The code that I have right now prints to my default HP printer:

DoCmd.OpenReport "rptSearchReport"

which works fine. I read through the forums and there seems to be no definitive answer to how to print a report to a pdf file. The only solution I see is to change my Windows default printer to Adobe PDF, but I don't want to do that. Or maybe if the user clicks the button and a window pops up and asks them which printer they want to print to. That would be handy too.

Any suggestions?

Thanks,

Wayne.
Mar 30 '07 #1
4 7405
developing
110 100+
sounds like you need code that will call the print API....quite complicated and I have no idea how....

you could try print to file function and play around with the code...that might get teh ball rolling
Mar 30 '07 #2
Thanks for the reply,

I'm still fiddling with this issue, to no avail.

Anyone else have any suggestions?
Apr 7 '07 #3
ADezii
8,834 Expert 8TB
Hi all,

I'm trying to set up two buttons on a form:
one to print a report to my printer (which happens to be set as default printer in windows) and,
another to convert the report to a pdf file (which is not set as default)

Is there a way to write code in the buttom click event to change which printer it prints to (either \\W1\HP Color LaserJet 1500 or Adobe PDF)?

The code that I have right now prints to my default HP printer:

DoCmd.OpenReport "rptSearchReport"

which works fine. I read through the forums and there seems to be no definitive answer to how to print a report to a pdf file. The only solution I see is to change my Windows default printer to Adobe PDF, but I don't want to do that. Or maybe if the user clicks the button and a window pops up and asks them which printer they want to print to. That would be handy too.

Any suggestions?

Thanks,

Wayne.
To change the Default Printer to the LaserJet 1500, then revert back to the Default prior to the change:
Expand|Select|Wrap|Line Numbers
  1. Set Application.Printer = Application.Printers("\\W1\HP Color LaserJet 1500")
  2.  
  3. DoCmd.OpenReport "rptSearchReport"
  4.  
  5. 'Now, set the Default Printer back to the way it was
  6. Set Application.Printer = Nothing
To change the Default Printer to the Adobe PDF, then revert back to the Default prior to the change:
Expand|Select|Wrap|Line Numbers
  1. Set Application.Printer = Application.Printers("Adobe PDF")
  2.  
  3. DoCmd.OpenReport "rptSearchReport"
  4.  
  5. 'Now, set the Default Printer back to the way it was
  6. Set Application.Printer = Nothing
Hope this helps.
Apr 8 '07 #4
Thank you, I will try it out :)
Wayne.

To change the Default Printer to the LaserJet 1500, then revert back to the Default prior to the change:
Expand|Select|Wrap|Line Numbers
  1. Set Application.Printer = Application.Printers("\\W1\HP Color LaserJet 1500")
  2.  
  3. DoCmd.OpenReport "rptSearchReport"
  4.  
  5. 'Now, set the Default Printer back to the way it was
  6. Set Application.Printer = Nothing
To change the Default Printer to the Adobe PDF, then revert back to the Default prior to the change:
Expand|Select|Wrap|Line Numbers
  1. Set Application.Printer = Application.Printers("Adobe PDF")
  2.  
  3. DoCmd.OpenReport "rptSearchReport"
  4.  
  5. 'Now, set the Default Printer back to the way it was
  6. Set Application.Printer = Nothing
Hope this helps.
Apr 19 '07 #5

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

Similar topics

10
by: Brian Hanson | last post by:
Hi, I am trying to programmatically print a pdf file via an asp.net application. I have seen other postings that mention the following code used or something similar to it in a vb.net app. ...
1
by: BJS | last post by:
Sorry for the cross-posting, but based on the number of people I have seen ask for a solution to this problem, I hope by cross-posting this, that it will help a lot of people out of a common...
16
by: cyranoVR | last post by:
This is the approach I used to automate printing of Microsoft Access reports to PDF format i.e. unattended and without annoying "Save As..." dialogs, and - more importantly - without having to use...
11
by: IC_Clearly | last post by:
I'm running Server 2003 and wonder how well WTS works when printing an Access report to a client. Any suggestions would be appreciated. Thanks. IC
4
by: Rob T | last post by:
I have a small VB program that has a printing module...very simple....and works great. However, If I try to print to a generic printer, I get the following error: "The data area passed to a...
5
by: Tom | last post by:
I am converting an old application that was printing directly to a specialized printer device (i.e. a special label printer). It was doing this by opening a file with the file path of 'LPT1:' and...
3
by: Mika M | last post by:
Hi all! I have made an application for printing simple barcode labels using PrintDocument object, and it's working fine. Barcode printer that I use is attached to the computer, and this...
6
by: VJ | last post by:
I am able to print to File, which I am doing fine in our Program now. I want to be able to take this file and Print to a printer. Vijay
2
by: Brad Pears | last post by:
I have a vb.net 2005 application and am using the print preview screen. This screen has a printer icon on it that the user can use to print the document currently being viewed. It uses the default...
18
by: Brett | last post by:
I have an ASP.NET page that displays work orders in a GridView. In that GridView is a checkbox column. When the user clicks a "Print" button, I create a report, using the .NET Framework printing...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.