473,466 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Create 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 12554
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.net 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.dll" Alias
"ShellExecuteA" _
(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
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...
0
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...
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...
1
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...
3
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...
1
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...
1
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...
1
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...
13
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...
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,...
1
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...
0
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.