|
-
Sep 11th, 2006, 06:06 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Printing pdf or doc files
Is getting VB to use Acrobat the only approach to doing this? (it's a shame users would then need to have or install an extra programme).
If it *is* the only way, will Acrobat Reader (and/or Word Reader, or whatever it's called) do the job or would the user have to have the full, expensive versions for it to work?
Thanks in advance,
Paul
-
Sep 11th, 2006, 06:09 AM
#2
Re: Printing pdf or doc files
Is all you want to do is print it as your thread title indicates?
-
Sep 11th, 2006, 06:13 AM
#3
Thread Starter
Fanatic Member
Re: Printing pdf or doc files
 Originally Posted by Hack
Is all you want to do is print it as your thread title indicates?
Yes.
Paul.
-
Sep 11th, 2006, 06:25 AM
#4
Re: Printing pdf or doc files
-
Sep 11th, 2006, 06:27 AM
#5
Re: Printing pdf or doc files
Try the ShellExecute API with "Print:" instead of "Open:" or "mailto:"
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
-
Sep 11th, 2006, 06:40 AM
#6
Thread Starter
Fanatic Member
Re: Printing pdf or doc files
 Originally Posted by Hack
Yes, that works a treat, many thanks, but it gives the focus to Acrobat and doesn't close it when it's finished. Is there a way to stop the former and do the latter?
Paul.
-
Sep 11th, 2006, 07:00 AM
#7
Re: Printing pdf or doc files
Do you know the caption of the window?
-
Sep 11th, 2006, 07:33 AM
#8
Thread Starter
Fanatic Member
Re: Printing pdf or doc files
 Originally Posted by Hack
Do you know the caption of the window?
It's "Setting work".
Paul.
-
Sep 11th, 2006, 07:35 AM
#9
Re: Printing pdf or doc files
My test document is called "Progress Reports". Change as approrpriate. You will need to feed this the exact caption and it will work like a charm. 
VB Code:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long
Private Const WM_CLOSE = &H10
Private Sub cmdCloseApp_Click()
Dim lngCloseIt As Long
lngCloseIt = FindWindow(vbNullString, "Adobe Reader - [Progress Reports]")
PostMessage lngCloseIt, WM_CLOSE, CLng(0), CLng(0)
End Sub
-
Sep 11th, 2006, 08:19 AM
#10
Thread Starter
Fanatic Member
Re: Printing pdf or doc files
Thanks for that!
This is most odd, though - I pasted in your new declarations but not the actual code for cmdCloseApp_Click and I now find that my app prints the pdf without losing focus to Acrobat! An instance of Acrobat is still loaded, though (but I can live with that because users will typically print out 5 or 6 docs at a time - what I didn't want was for Acrobat to be the topmost window after the print call).
I wonder why your first code appeared not to behave how I wanted but now it does!
Paul.
-
Sep 11th, 2006, 08:40 AM
#11
Re: Printing pdf or doc files
 Originally Posted by paulorton
I wonder why your first code appeared not to behave how I wanted but now it does!
Without being able to look at your program and see how it does what it does, this is diffcult to determine.
However, if you consider this resolved, would you please pull down the Thread Tools menu and click the Mark Thread Resolved menu item? That will let everyone know that you have your answer.
Thank you.
-
Sep 11th, 2006, 08:54 AM
#12
Thread Starter
Fanatic Member
Re: Printing pdf or doc files
Thanks to everyone who read and/or answered this thread. This forum is an amazing resource!
Paul.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|