mytfein
asked on
print pdf to a printer - (picking up on another member's post of the last week)
Hi EE,
Requesting help on this recent EE post, please:
https://www.experts-exchange.com/questions/24520474/Access-code-for-closiing-an-object.html?cid=238&anchorAnswerId=24739541#a24739541
Providentially, I am working on the same problem and discovered this dialogue:
A few years ago (a2000) I received from another forum help to print a pdf using sendkeys.
Now, i am using a2003:, and the logic is not working to print the pdf to a real printer.
i followed Cap's advice, yet:
the system is not understanding the foreground window to be Adobe -
if i'm in breakpoint mode, it thinks the current window is vba
if i run not in breakpoint mode (i'm running this mdb like a quasi vbs script), it thinks it's in
vbs mode.
In the code window is code per Cap's instructions.
AFterwards, the code window shows my old logic that opened pdf for printing, sendkeys
to print, then closed pdf
In this environment:
I need to print to another network printer, so added sendkeys to change printer
all of sudden the application.hyperlink is popping up a microsoft message box
so i see that doing a shell to adobe is equivalent.
Please advise, tx, sandra
i will open a new post, i just wanted to catch your attention, if you have time....
tx, sandra
Requesting help on this recent EE post, please:
https://www.experts-exchange.com/questions/24520474/Access-code-for-closiing-an-object.html?cid=238&anchorAnswerId=24739541#a24739541
Providentially, I am working on the same problem and discovered this dialogue:
A few years ago (a2000) I received from another forum help to print a pdf using sendkeys.
Now, i am using a2003:, and the logic is not working to print the pdf to a real printer.
i followed Cap's advice, yet:
the system is not understanding the foreground window to be Adobe -
if i'm in breakpoint mode, it thinks the current window is vba
if i run not in breakpoint mode (i'm running this mdb like a quasi vbs script), it thinks it's in
vbs mode.
In the code window is code per Cap's instructions.
AFterwards, the code window shows my old logic that opened pdf for printing, sendkeys
to print, then closed pdf
In this environment:
I need to print to another network printer, so added sendkeys to change printer
all of sudden the application.hyperlink is popping up a microsoft message box
so i see that doing a shell to adobe is equivalent.
Please advise, tx, sandra
i will open a new post, i just wanted to catch your attention, if you have time....
tx, sandra
Option Compare Database
Option Explicit
Public Declare Function GetForegroundWindow Lib "user32" () As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_CLOSE = &H10
Public lngAdobehWnd As Long
Public Sub TestPDF()
Call g005_PrintPdfByHyperLink("C:\ARG_99_Scripts\ARG_99_DailyElectives_script\AutomatedDailyElectivesListing.pdf", _
False, _
"Y")
End Sub
Public Sub g005_PrintPdfByHyperLink(strFilePath As String, _
blnRunDuringDay As Boolean, _
strBackPrintTestPage As String)
Shell "C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe" & " " & strFilePath
SendKeys "%FP", True
SendKeys "Student Affairs", True
If strBackPrintTestPage = "Y" Then
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "1", True 'for testing
End If
SendKeys "{enter}", True
DoEvents
lngAdobehWnd = GetForegroundWindow
'close adobe
Call SendMessage(lngAdobehWnd, WM_CLOSE, 0, 0)
End Sub
Public Sub old_g005_PrintPdfByHyperLink(ByVal strFilePath As String, _
blnRunDuringDay As Boolean, _
strBackPrintTestPage As String)
' opening pdf via adobe
' FilePath is full path of .pdf file to be printed
' http://support.microsoft.com/default.aspx/kb/829072
' Application.FollowHyperlink strFilePath
' SendKeys "%FP{enter}^q", True
Shell "C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe" & " " & strFilePath
If blnRunDuringDay = False Then
' g_strScreenMsg = "* * Please wait as PDF opens and self-prints * * "
' DisplayScreenMsg (enTypeScreenMsg.enTypeScreenInfoMsg)
' Allow time for opening of associated
' application and stabilization of display
g010_p_wait 500
' Invoke print dialog box (Alt + f + p)
SendKeys "%fp", True
' SendKeys "Diane's printer", True
SendKeys "Student Affairs", True
' Allow time for stabilization
g010_p_wait 100
' Press Enter (This is equivalent to clicking OK
' in the print dialog box)
If strBackPrintTestPage = "Y" Then
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "1", True 'for testing
End If
SendKeys "{ENTER}", True
' Allow time for stabilization
g010_p_wait 100
' Close & Exit pdf application (Alt + f + x)
SendKeys "^Q", True
' g_strScreenMsg = "* * Successful Print * * "
' DisplayScreenMsg (enTypeScreenMsg.enTypeScreenInfoMsg)
Else
' g_strScreenMsg = "* * Successful Preview * * "
' DisplayScreenMsg (enTypeScreenMsg.enTypeScreenInfoMsg)
End If
End Sub
Public Sub g010_p_wait(ByVal Tmr As Long)
' Introduces time delay of Tmr cycles
Dim Cnt As Long
For Cnt = 1 To Tmr
DoEvents
Next
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi TheNelson,
just wondering:
a) do you use reader (which vers) ?
b) do you use adobe pro (which vers)
c) do you use foxit simply to print via batch, or is foxit your "default" reader
d) if foxit is just for batch, is your windows explorer setup to open pdf files with Adobe reader
and not foxit?
tx, s
just wondering:
a) do you use reader (which vers) ?
b) do you use adobe pro (which vers)
c) do you use foxit simply to print via batch, or is foxit your "default" reader
d) if foxit is just for batch, is your windows explorer setup to open pdf files with Adobe reader
and not foxit?
tx, s
ASKER
Hi guys,
I posted yesterday on another forum:
MS_Access_Professionals@ya hoogroups. com
Got a response that recommends this approach:
http://accessblog.net/2008/01/printing-pdf-from-code.html
I have not tried it yet... just sharing... tx, sandra
I posted yesterday on another forum:
MS_Access_Professionals@ya
Got a response that recommends this approach:
http://accessblog.net/2008/01/printing-pdf-from-code.html
I have not tried it yet... just sharing... tx, sandra
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
a) I thorougly re-read bartzinc's posts, bec. boag200/Jeff said it was resolved.
I saw that bartzinc printed directly from access and not pdf.
Great, so I modified my code this morning to print from excel and not even open pdf.
b) Before I understood (a), I found a diff. post by TheNelson where he recommends foxit.
So I downloaded it. On Fri, I downloaded Adobe updates. Not sure if the updates or foxit
changed my pc settings regarding Adobe. Pdfs now require me to confirm opening them
in IE, or when I do an Application.followhyperlin
You see, under A2000 i had sendkeys logic for pdf that worked off a form's button.
Now under A2003, when running as quasi VBS script, the Access mdb has control over
pdf screen, and sendkeys not working. Before sendkeys, i did an application.followhyperlin
with pdf path to open pdf, but as i said before, now i'm getting a confirm box to open pdf where
before foxit install, pdf opened seamlessly.
so I uninstalled foxit...
so I may have to call IT to reinstall Adobe....
so am hestitant in using foxit
c) so I explored EE other ideas of doing shell to adobe with pdf path
(to avoid confirm msg box of Application.hyperlink)
but, could not determine handle to close pdf.
d) I would be very interested in Capricorn1's idea of determining the handle of pdf
to issue a close. This would be useful in opening/printing a pdf file that i did not create.
Our dept has pdfs that other depts created, so i cannot print from its orig. app (for ex: publisher).
e) that's why although (a) meets my needs for now,
(d) would be very useful...
f) i googled and fond this to try to make (d) work,
i pasted the logic from this link into module but it did not work for me...
http://support.microsoft.com/kb/242308
if you have any ideas on d,e,f that would be great, tx, sandra