Connecting Tech Pros Worldwide Help | Site Map

Sending a pdf file to default printer from vba

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 13th, 2005, 07:53 AM
cantelow@csd.net
Guest
 
Posts: n/a
Default 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


  #2  
Old November 13th, 2005, 07:53 AM
cantelow@csd.net
Guest
 
Posts: n/a
Default Re: Sending a pdf file to default printer from vba

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.

  #3  
Old November 13th, 2005, 07:53 AM
Tom van Stiphout
Guest
 
Posts: n/a
Default Re: Sending a pdf file to default printer from vba

On 3 Mar 2005 14:40:54 -0800, cantelow@csd.net wrote:

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

-Tom.

[color=blue]
>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[/color]

  #4  
Old November 13th, 2005, 07:54 AM
cantelow@csd.net
Guest
 
Posts: n/a
Default Re: Sending a pdf file to default printer from vba

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

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.