473,545 Members | 2,063 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sending a pdf file to default printer from vba

Hi folks.

I've got a need to print a preexisting pdf file after an Access report,
as a pseudo attachment.

Seems it should be easy, but how do I send a pdf file to the default
printer? Do I need to run something from shell()? A pointer to the
name of a command to use would be very appreciated- then I would be
armed with a good keyword to use in google, heh.

Thanks!
Ann

Nov 13 '05 #1
3 12561
This is Access 97, I should have mentioned. Also, I have pdf995
installed, wonder if I should try to find a way to use that from the
command line.
--Thanks.

Nov 13 '05 #2
On 3 Mar 2005 14:40:54 -0800, ca******@csd.ne t wrote:

Actually, if you use the ShellExecute Windows API with the "Print"
verb, that should work wonderfully.

-Tom.

Hi folks.

I've got a need to print a preexisting pdf file after an Access report,
as a pseudo attachment.

Seems it should be easy, but how do I send a pdf file to the default
printer? Do I need to run something from shell()? A pointer to the
name of a command to use would be very appreciated- then I would be
armed with a good keyword to use in google, heh.

Thanks!
Ann


Nov 13 '05 #3
Thanks, Tom!

Yep, that has handled it for me.

I needed this API declare:

Private Declare Function ShellExecute Lib "shell32.dl l" Alias
"ShellExecu teA" _
(ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

-And in my routine, this call printed the file:

Dim lRet as long

lRet = ShellExecute(0, "print", "c:\(path to file)\(filename .pdf)", _
"", "", 1)

If lRet is 2, it apparently means file not found. I got the value of
31 when I had the parameters in the wrong positions. 32 and more means
success.

I think it's likely that it used adobe to print this on my machine,
since I also have that installed. I believe it looks at the default
app for pdf extension to decide what to do for "print".

This will also print .doc and .txt files. It brings up a separate
temporary window for each of those, but I believe that can be controled
with the last parameter to the call.

"Print" is not a command that can be run first from the dos prompt to
test, that doesn't appear to make sense. My poor understanding of what
apis actually are had me trying that for a small while.

Thanks heaps, I'm in business.
-Ann

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2221
by: Brian Boccia | last post by:
I'm trying to print a report from an ASP.Net button click event. In my application I use a ReportDocument object to load a .rpt file and display the file in an IE window. In that window I have an export button with a dropdown to allow the user to select a file format to export to or just to send it to a printer. When I select the printer...
0
2565
by: Esmee | last post by:
Hi there, I have created an Access 2002 db which contains several reports. Some reports need to be printed on a Laserjet and others on a Labelprinter. One of my clients wants to be able to print the same reports to 3 different laserjets and to 3 different labelprinters. (They work with the db on 3 different units each with their own...
16
48836
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 a commercial program such as Adobe Acrobat and its associated API. The technique uses Ghostscript and Redirection Port Monitor - two free...
1
21450
by: Ravikanth[MVP] | last post by:
Hello, You can use the PrintDocument component to use the default printer. If you don't specify a printer to the PrintDocument object, by default, it will use the default printer. This is a sample code; private void print_Click(object sender, System.EventArgs
3
8516
by: Rick R | last post by:
We need to change the paper size for the default printer before printing a PDF file from within a VB.Net application. printDocument printerSettings is not appropriate as there is no document to print. Any help is greately appreciated.
1
5438
by: i8mypnuts | last post by:
Could someone please help? I am using the 'defaultprt.zip' tool provided by Ken Getz to change the default printer via VBA code (code below). My problem is that once the default printer has been changed, Access 2003 still directs the report to the former default printer. Access 2003 picks up the new default printer setting only after I have...
1
2347
by: groulder | last post by:
hi all, i have a problem with a network database that's used by a lot of people. people are finding, they will start the database, and if the mouse is moved over the print icon, the tooltip appears to show which printer it will print to as normal. this printer however is a printer that the user doesn't even have installed.
1
6993
by: Robert Dufour | last post by:
I have a file c:\test.pdf that I simply need to send to the default printer from within my vb.net code I've been seeing samples that show how to print text to a printer and they handle page counting etc. All I need to do is just to pick up the whole PDF file and give a command to print it but I can't put my finger on how to do that. The...
13
9073
by: Mark Rae | last post by:
Hi, I have used the code below to return the default printer in 32-bit WinXP Pro, but now that I am running 64-bit Vista Business I'm getting an error: using System.Drawing.Printing; using (PrintDocument objPrintDocument = new PrintDocument()) { string strDefaultPrinter =
0
7470
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7405
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
7659
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7428
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5975
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...
1
5334
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1019
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
709
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.