By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,453 Members | 3,183 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,453 IT Pros & Developers. It's quick & easy.

Open/print PDF-file from Access

P: n/a
Dear All,

All 3 codes, copied from internet, triggers error 429 : ActiveX component
can't create object !
No compile error.
I have the reference set to Adobe Acrobat 7.0 Type Library
I do not have the full version of Adobe Reader 7.0 !

The final goal is to print a PDF-file from access after selecting the file
in a browser.

Please help!

Filip

------------------------------------------------------------------
Private Sub Command0_Click()

Dim gApp As Acrobat.Acroapp
Dim gPDdoc As Acrobat.AcroPDDoc

Dim jso As Object
gApp = CreateObject("AcroExch.App")
gPDdoc = CreateObject("AcroExch.PDDoc")
If gPDdoc.Open("c:\adobe.pdf") Then
jso.gPDdoc.GetJSObject
jso.console.Show
jso.console.Clear
jso.console.println ("Hello, Adobe !")
gApp.Show
End If

End Sub
------------------------------------------------------------------
Private Sub Command1_Click()

Dim Acroapp As CAcroApp
Dim avFile As CAcroAVDoc
Dim jso As Object
'Start Acrobat in the background
Set Acroapp = CreateObject("AcroExch.App")

'Uncomment the following line if you want to watch the program run
Acroapp.Show

Set avFile = CreateObject("AcroExch.PDDoc") 'This is the code file

'Open the already created code file
If avFile.Open("c:\adobe.pdf", "PDFfilip") Then
jso.gPDdoc.GetJSObject
jso.console.Show
jso.console.Clear
jso.console.println ("Hello, Adobe !")
Acroapp.Show
End If
End Sub
------------------------------------------------------------------
Private Sub Command2_Click()

Dim AcroExchApp As Object
Dim AcroExchPDDoc As Object

Set AcroExchApp = CreateObject("AcroExch.App")
Set AcroExchPDDoc = CreateObject("AcroExch.PDDoc")

' Show the Acrobat Exchange window
AcroExchApp.Show

AcroExchPDDoc.Open "c:\adobe.pdf"
AcroExchPDDoc.PrintOut

' Close the PDDoc
AcroExchPDDoc.Close

' Close Acrobat Exchange
AcroExchApp.Exit

End Sub
------------------------------------------------------------------
Aug 3 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Fri, 03 Aug 2007 10:43:28 GMT, "Filips Benoit"
<be***********@telenet.bewrote:

I would use a 1-liner: use the ShellExecute API with the Print verb.
That would be the equivalent of dropping the PDF file on the Default
Printer icon. Windows will invoke the registered app and tell it you
wanted to print that file.

-Tom.

>Dear All,

All 3 codes, copied from internet, triggers error 429 : ActiveX component
can't create object !
No compile error.
I have the reference set to Adobe Acrobat 7.0 Type Library
I do not have the full version of Adobe Reader 7.0 !

The final goal is to print a PDF-file from access after selecting the file
in a browser.

Please help!

Filip

------------------------------------------------------------------
Private Sub Command0_Click()

Dim gApp As Acrobat.Acroapp
Dim gPDdoc As Acrobat.AcroPDDoc

Dim jso As Object
gApp = CreateObject("AcroExch.App")
gPDdoc = CreateObject("AcroExch.PDDoc")
If gPDdoc.Open("c:\adobe.pdf") Then
jso.gPDdoc.GetJSObject
jso.console.Show
jso.console.Clear
jso.console.println ("Hello, Adobe !")
gApp.Show
End If

End Sub
------------------------------------------------------------------
Private Sub Command1_Click()

Dim Acroapp As CAcroApp
Dim avFile As CAcroAVDoc
Dim jso As Object
'Start Acrobat in the background
Set Acroapp = CreateObject("AcroExch.App")

'Uncomment the following line if you want to watch the program run
Acroapp.Show

Set avFile = CreateObject("AcroExch.PDDoc") 'This is the code file

'Open the already created code file
If avFile.Open("c:\adobe.pdf", "PDFfilip") Then
jso.gPDdoc.GetJSObject
jso.console.Show
jso.console.Clear
jso.console.println ("Hello, Adobe !")
Acroapp.Show
End If
End Sub
------------------------------------------------------------------
Private Sub Command2_Click()

Dim AcroExchApp As Object
Dim AcroExchPDDoc As Object

Set AcroExchApp = CreateObject("AcroExch.App")
Set AcroExchPDDoc = CreateObject("AcroExch.PDDoc")

' Show the Acrobat Exchange window
AcroExchApp.Show

AcroExchPDDoc.Open "c:\adobe.pdf"
AcroExchPDDoc.PrintOut

' Close the PDDoc
AcroExchPDDoc.Close

' Close Acrobat Exchange
AcroExchApp.Exit

End Sub
------------------------------------------------------------------
Aug 3 '07 #2

P: n/a
OK, works fine but it opens acrobat without closing it !

Filip
"Tom van Stiphout" <no*************@cox.netwrote in message
news:kg********************************@4ax.com...
On Fri, 03 Aug 2007 10:43:28 GMT, "Filips Benoit"
<be***********@telenet.bewrote:

I would use a 1-liner: use the ShellExecute API with the Print verb.
That would be the equivalent of dropping the PDF file on the Default
Printer icon. Windows will invoke the registered app and tell it you
wanted to print that file.

-Tom.

>>Dear All,

All 3 codes, copied from internet, triggers error 429 : ActiveX component
can't create object !
No compile error.
I have the reference set to Adobe Acrobat 7.0 Type Library
I do not have the full version of Adobe Reader 7.0 !

The final goal is to print a PDF-file from access after selecting the file
in a browser.

Please help!

Filip

------------------------------------------------------------------
Private Sub Command0_Click()

Dim gApp As Acrobat.Acroapp
Dim gPDdoc As Acrobat.AcroPDDoc

Dim jso As Object
gApp = CreateObject("AcroExch.App")
gPDdoc = CreateObject("AcroExch.PDDoc")
If gPDdoc.Open("c:\adobe.pdf") Then
jso.gPDdoc.GetJSObject
jso.console.Show
jso.console.Clear
jso.console.println ("Hello, Adobe !")
gApp.Show
End If

End Sub
------------------------------------------------------------------
Private Sub Command1_Click()

Dim Acroapp As CAcroApp
Dim avFile As CAcroAVDoc
Dim jso As Object
'Start Acrobat in the background
Set Acroapp = CreateObject("AcroExch.App")

'Uncomment the following line if you want to watch the program run
Acroapp.Show

Set avFile = CreateObject("AcroExch.PDDoc") 'This is the code file

'Open the already created code file
If avFile.Open("c:\adobe.pdf", "PDFfilip") Then
jso.gPDdoc.GetJSObject
jso.console.Show
jso.console.Clear
jso.console.println ("Hello, Adobe !")
Acroapp.Show
End If
End Sub
------------------------------------------------------------------
Private Sub Command2_Click()

Dim AcroExchApp As Object
Dim AcroExchPDDoc As Object

Set AcroExchApp = CreateObject("AcroExch.App")
Set AcroExchPDDoc = CreateObject("AcroExch.PDDoc")

' Show the Acrobat Exchange window
AcroExchApp.Show

AcroExchPDDoc.Open "c:\adobe.pdf"
AcroExchPDDoc.PrintOut

' Close the PDDoc
AcroExchPDDoc.Close

' Close Acrobat Exchange
AcroExchApp.Exit

End Sub
------------------------------------------------------------------

Aug 3 '07 #3

P: n/a
On Fri, 03 Aug 2007 15:54:22 GMT, "Filips Benoit"
<be***********@telenet.bewrote:

That's annoying, but with 2 more lines of code you can find the window
handle of the main window of that application (FindWindow), and send
it a WM_CLOSE message (PostMessage).

-Tom.

>OK, works fine but it opens acrobat without closing it !

Filip
"Tom van Stiphout" <no*************@cox.netwrote in message
news:kg********************************@4ax.com.. .
>On Fri, 03 Aug 2007 10:43:28 GMT, "Filips Benoit"
<be***********@telenet.bewrote:

I would use a 1-liner: use the ShellExecute API with the Print verb.
That would be the equivalent of dropping the PDF file on the Default
Printer icon. Windows will invoke the registered app and tell it you
wanted to print that file.

-Tom.

>>>Dear All,

All 3 codes, copied from internet, triggers error 429 : ActiveX component
can't create object !
No compile error.
I have the reference set to Adobe Acrobat 7.0 Type Library
I do not have the full version of Adobe Reader 7.0 !

The final goal is to print a PDF-file from access after selecting the file
in a browser.

Please help!

Filip

------------------------------------------------------------------
Private Sub Command0_Click()

Dim gApp As Acrobat.Acroapp
Dim gPDdoc As Acrobat.AcroPDDoc

Dim jso As Object
gApp = CreateObject("AcroExch.App")
gPDdoc = CreateObject("AcroExch.PDDoc")
If gPDdoc.Open("c:\adobe.pdf") Then
jso.gPDdoc.GetJSObject
jso.console.Show
jso.console.Clear
jso.console.println ("Hello, Adobe !")
gApp.Show
End If

End Sub
------------------------------------------------------------------
Private Sub Command1_Click()

Dim Acroapp As CAcroApp
Dim avFile As CAcroAVDoc
Dim jso As Object
'Start Acrobat in the background
Set Acroapp = CreateObject("AcroExch.App")

'Uncomment the following line if you want to watch the program run
Acroapp.Show

Set avFile = CreateObject("AcroExch.PDDoc") 'This is the code file

'Open the already created code file
If avFile.Open("c:\adobe.pdf", "PDFfilip") Then
jso.gPDdoc.GetJSObject
jso.console.Show
jso.console.Clear
jso.console.println ("Hello, Adobe !")
Acroapp.Show
End If
End Sub
------------------------------------------------------------------
Private Sub Command2_Click()

Dim AcroExchApp As Object
Dim AcroExchPDDoc As Object

Set AcroExchApp = CreateObject("AcroExch.App")
Set AcroExchPDDoc = CreateObject("AcroExch.PDDoc")

' Show the Acrobat Exchange window
AcroExchApp.Show

AcroExchPDDoc.Open "c:\adobe.pdf"
AcroExchPDDoc.PrintOut

' Close the PDDoc
AcroExchPDDoc.Close

' Close Acrobat Exchange
AcroExchApp.Exit

End Sub
------------------------------------------------------------------
Aug 4 '07 #4

P: n/a
Sorry Tom,

But can't find the main window of Adobe Reader 7.0 .
I have found several window-names for Adobe Reader but none is matching !
Or, like most cases I'll must have made some stupidity but can't see it !

Can you send my those 2(?) lines.

Thanks,

Filip

****************************** tested code ****************************
Option Compare Database
Option Explicit
Private Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long

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 Declare Function IsWindow Lib "user32" _
(ByVal hwnd As Long) As Long

Private Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long

Private Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hwnd As Long, _
lpdwProcessId As Long) As Long

'Constants that are used by the API
Const WM_CLOSE = &H10
Const INFINITE = &HFFFFFFFF
Const SYNCHRONIZE = &H100000

Private Sub Command4_Click()

On Error GoTo errHandling

Dim ret As Variant
ret = ShellExecute(0, "print", "c:\adobe.pdf", vbNullString, 0, 0)

DoCmd.Hourglass True

Dim hWindow As Long
Dim hThread As Long
Dim hProcess As Long
Dim lProcessId As Long
Dim lngResult As Long
Dim lngReturnValue As Long
Dim iLoop As Long

Do While hWindow = 0
iLoop = iLoop + 1
hWindow = FindWindow(vbNullString, "Adobe Reader-[adobe.pdf]")
If hWindow = 0 Then hWindow = FindWindow(vbNullString, "Adobe
Reader - [adobe.pdf]")
If hWindow = 0 Then hWindow = FindWindow(vbNullString, "Adobe
Reader")
If hWindow = 0 Then hWindow = FindWindow(vbNullString, "Adobe
Acrobat")
If hWindow = 0 Then hWindow = FindWindow("AVL_AVPopup", "")
If iLoop 50 Then Exit Do
Loop

MsgBox hWindow

hThread = GetWindowThreadProcessId(hWindow, lProcessId)
hProcess = OpenProcess(SYNCHRONIZE, 0&, lProcessId)
lngReturnValue = PostMessage(hWindow, WM_CLOSE, 0&, 0&)
lngResult = WaitForSingleObject(hProcess, INFINITE)
DoCmd.Hourglass False

Exit Sub

errHandling:

DoCmd.Hourglass False
MsgBox err.Number & " " & err.Description

End Sub
************************************************** *****************************************


"Tom van Stiphout" <no*************@cox.netwrote in message
news:i2********************************@4ax.com...
On Fri, 03 Aug 2007 15:54:22 GMT, "Filips Benoit"
<be***********@telenet.bewrote:

That's annoying, but with 2 more lines of code you can find the window
handle of the main window of that application (FindWindow), and send
it a WM_CLOSE message (PostMessage).

-Tom.

>>OK, works fine but it opens acrobat without closing it !

Filip
"Tom van Stiphout" <no*************@cox.netwrote in message
news:kg********************************@4ax.com. ..
>>On Fri, 03 Aug 2007 10:43:28 GMT, "Filips Benoit"
<be***********@telenet.bewrote:

I would use a 1-liner: use the ShellExecute API with the Print verb.
That would be the equivalent of dropping the PDF file on the Default
Printer icon. Windows will invoke the registered app and tell it you
wanted to print that file.

-Tom.
Dear All,

All 3 codes, copied from internet, triggers error 429 : ActiveX
component
can't create object !
No compile error.
I have the reference set to Adobe Acrobat 7.0 Type Library
I do not have the full version of Adobe Reader 7.0 !

The final goal is to print a PDF-file from access after selecting the
file
in a browser.

Please help!

Filip

------------------------------------------------------------------
Private Sub Command0_Click()

Dim gApp As Acrobat.Acroapp
Dim gPDdoc As Acrobat.AcroPDDoc

Dim jso As Object
gApp = CreateObject("AcroExch.App")
gPDdoc = CreateObject("AcroExch.PDDoc")
If gPDdoc.Open("c:\adobe.pdf") Then
jso.gPDdoc.GetJSObject
jso.console.Show
jso.console.Clear
jso.console.println ("Hello, Adobe !")
gApp.Show
End If

End Sub
------------------------------------------------------------------
Private Sub Command1_Click()

Dim Acroapp As CAcroApp
Dim avFile As CAcroAVDoc
Dim jso As Object
'Start Acrobat in the background
Set Acroapp = CreateObject("AcroExch.App")

'Uncomment the following line if you want to watch the program run
Acroapp.Show

Set avFile = CreateObject("AcroExch.PDDoc") 'This is the code file

'Open the already created code file
If avFile.Open("c:\adobe.pdf", "PDFfilip") Then
jso.gPDdoc.GetJSObject
jso.console.Show
jso.console.Clear
jso.console.println ("Hello, Adobe !")
Acroapp.Show
End If
End Sub
------------------------------------------------------------------
Private Sub Command2_Click()

Dim AcroExchApp As Object
Dim AcroExchPDDoc As Object

Set AcroExchApp = CreateObject("AcroExch.App")
Set AcroExchPDDoc = CreateObject("AcroExch.PDDoc")

' Show the Acrobat Exchange window
AcroExchApp.Show

AcroExchPDDoc.Open "c:\adobe.pdf"
AcroExchPDDoc.PrintOut

' Close the PDDoc
AcroExchPDDoc.Close

' Close Acrobat Exchange
AcroExchApp.Exit

End Sub
------------------------------------------------------------------


Aug 4 '07 #5

P: n/a
Solution is to wait 1 second before closing Adobe.
Window not found because not open yet !

Thanks
"Filips Benoit" <be***********@telenet.bewrote in message
news:5a*********************@phobos.telenet-ops.be...
Sorry Tom,

But can't find the main window of Adobe Reader 7.0 .
I have found several window-names for Adobe Reader but none is matching !
Or, like most cases I'll must have made some stupidity but can't see it !

Can you send my those 2(?) lines.

Thanks,

Filip

****************************** tested code ****************************
Option Compare Database
Option Explicit
Private Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long

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 Declare Function IsWindow Lib "user32" _
(ByVal hwnd As Long) As Long

Private Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long

Private Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hwnd As Long, _
lpdwProcessId As Long) As Long

'Constants that are used by the API
Const WM_CLOSE = &H10
Const INFINITE = &HFFFFFFFF
Const SYNCHRONIZE = &H100000

Private Sub Command4_Click()

On Error GoTo errHandling

Dim ret As Variant
ret = ShellExecute(0, "print", "c:\adobe.pdf", vbNullString, 0, 0)

DoCmd.Hourglass True

Dim hWindow As Long
Dim hThread As Long
Dim hProcess As Long
Dim lProcessId As Long
Dim lngResult As Long
Dim lngReturnValue As Long
Dim iLoop As Long

Do While hWindow = 0
iLoop = iLoop + 1
hWindow = FindWindow(vbNullString, "Adobe Reader-[adobe.pdf]")
If hWindow = 0 Then hWindow = FindWindow(vbNullString, "Adobe
Reader - [adobe.pdf]")
If hWindow = 0 Then hWindow = FindWindow(vbNullString, "Adobe
Reader")
If hWindow = 0 Then hWindow = FindWindow(vbNullString, "Adobe
Acrobat")
If hWindow = 0 Then hWindow = FindWindow("AVL_AVPopup", "")
If iLoop 50 Then Exit Do
Loop

MsgBox hWindow

hThread = GetWindowThreadProcessId(hWindow, lProcessId)
hProcess = OpenProcess(SYNCHRONIZE, 0&, lProcessId)
lngReturnValue = PostMessage(hWindow, WM_CLOSE, 0&, 0&)
lngResult = WaitForSingleObject(hProcess, INFINITE)
DoCmd.Hourglass False

Exit Sub

errHandling:

DoCmd.Hourglass False
MsgBox err.Number & " " & err.Description

End Sub
************************************************** *****************************************


"Tom van Stiphout" <no*************@cox.netwrote in message
news:i2********************************@4ax.com...
>On Fri, 03 Aug 2007 15:54:22 GMT, "Filips Benoit"
<be***********@telenet.bewrote:

That's annoying, but with 2 more lines of code you can find the window
handle of the main window of that application (FindWindow), and send
it a WM_CLOSE message (PostMessage).

-Tom.

>>>OK, works fine but it opens acrobat without closing it !

Filip
"Tom van Stiphout" <no*************@cox.netwrote in message
news:kg********************************@4ax.com ...
On Fri, 03 Aug 2007 10:43:28 GMT, "Filips Benoit"
<be***********@telenet.bewrote:

I would use a 1-liner: use the ShellExecute API with the Print verb.
That would be the equivalent of dropping the PDF file on the Default
Printer icon. Windows will invoke the registered app and tell it you
wanted to print that file.

-Tom.
>Dear All,
>
>All 3 codes, copied from internet, triggers error 429 : ActiveX
>component
>can't create object !
>No compile error.
>I have the reference set to Adobe Acrobat 7.0 Type Library
>I do not have the full version of Adobe Reader 7.0 !
>
>The final goal is to print a PDF-file from access after selecting the
>file
>in a browser.
>
>Please help!
>
>Filip
>
>------------------------------------------------------------------
>Private Sub Command0_Click()
>
Dim gApp As Acrobat.Acroapp
Dim gPDdoc As Acrobat.AcroPDDoc
>
Dim jso As Object
gApp = CreateObject("AcroExch.App")
gPDdoc = CreateObject("AcroExch.PDDoc")
If gPDdoc.Open("c:\adobe.pdf") Then
jso.gPDdoc.GetJSObject
jso.console.Show
jso.console.Clear
jso.console.println ("Hello, Adobe !")
gApp.Show
End If
>
>End Sub
>------------------------------------------------------------------
>Private Sub Command1_Click()
>
>Dim Acroapp As CAcroApp
>Dim avFile As CAcroAVDoc
Dim jso As Object
>'Start Acrobat in the background
>Set Acroapp = CreateObject("AcroExch.App")
>
>'Uncomment the following line if you want to watch the program run
>Acroapp.Show
>
>Set avFile = CreateObject("AcroExch.PDDoc") 'This is the code file
>
>'Open the already created code file
If avFile.Open("c:\adobe.pdf", "PDFfilip") Then
jso.gPDdoc.GetJSObject
jso.console.Show
jso.console.Clear
jso.console.println ("Hello, Adobe !")
Acroapp.Show
End If
>End Sub
>------------------------------------------------------------------
>Private Sub Command2_Click()
>
>Dim AcroExchApp As Object
>Dim AcroExchPDDoc As Object
>
>Set AcroExchApp = CreateObject("AcroExch.App")
>Set AcroExchPDDoc = CreateObject("AcroExch.PDDoc")
>
>' Show the Acrobat Exchange window
>AcroExchApp.Show
>
>AcroExchPDDoc.Open "c:\adobe.pdf"
>AcroExchPDDoc.PrintOut
>
>' Close the PDDoc
>AcroExchPDDoc.Close
>
>' Close Acrobat Exchange
>AcroExchApp.Exit
>
>End Sub
>------------------------------------------------------------------
>



Aug 4 '07 #6

P: n/a
If you just need to open the pdf and let the user decide whether to print it
or not, use

application.followhyperlink "filename.pdf"
"Filips Benoit" <be***********@telenet.bewrote in message
news:5a*********************@phobos.telenet-ops.be...
Sorry Tom,

But can't find the main window of Adobe Reader 7.0 .
I have found several window-names for Adobe Reader but none is matching !
Or, like most cases I'll must have made some stupidity but can't see it !

Can you send my those 2(?) lines.

Thanks,

Filip

****************************** tested code ****************************
Option Compare Database
Option Explicit
Private Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long

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 Declare Function IsWindow Lib "user32" _
(ByVal hwnd As Long) As Long

Private Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long

Private Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hwnd As Long, _
lpdwProcessId As Long) As Long

'Constants that are used by the API
Const WM_CLOSE = &H10
Const INFINITE = &HFFFFFFFF
Const SYNCHRONIZE = &H100000

Private Sub Command4_Click()

On Error GoTo errHandling

Dim ret As Variant
ret = ShellExecute(0, "print", "c:\adobe.pdf", vbNullString, 0, 0)

DoCmd.Hourglass True

Dim hWindow As Long
Dim hThread As Long
Dim hProcess As Long
Dim lProcessId As Long
Dim lngResult As Long
Dim lngReturnValue As Long
Dim iLoop As Long

Do While hWindow = 0
iLoop = iLoop + 1
hWindow = FindWindow(vbNullString, "Adobe Reader-[adobe.pdf]")
If hWindow = 0 Then hWindow = FindWindow(vbNullString, "Adobe
Reader - [adobe.pdf]")
If hWindow = 0 Then hWindow = FindWindow(vbNullString, "Adobe
Reader")
If hWindow = 0 Then hWindow = FindWindow(vbNullString, "Adobe
Acrobat")
If hWindow = 0 Then hWindow = FindWindow("AVL_AVPopup", "")
If iLoop 50 Then Exit Do
Loop

MsgBox hWindow

hThread = GetWindowThreadProcessId(hWindow, lProcessId)
hProcess = OpenProcess(SYNCHRONIZE, 0&, lProcessId)
lngReturnValue = PostMessage(hWindow, WM_CLOSE, 0&, 0&)
lngResult = WaitForSingleObject(hProcess, INFINITE)
DoCmd.Hourglass False

Exit Sub

errHandling:

DoCmd.Hourglass False
MsgBox err.Number & " " & err.Description

End Sub
************************************************** *****************************************


"Tom van Stiphout" <no*************@cox.netwrote in message
news:i2********************************@4ax.com...
>On Fri, 03 Aug 2007 15:54:22 GMT, "Filips Benoit"
<be***********@telenet.bewrote:

That's annoying, but with 2 more lines of code you can find the window
handle of the main window of that application (FindWindow), and send
it a WM_CLOSE message (PostMessage).

-Tom.

>>>OK, works fine but it opens acrobat without closing it !

Filip
"Tom van Stiphout" <no*************@cox.netwrote in message
news:kg********************************@4ax.com ...
On Fri, 03 Aug 2007 10:43:28 GMT, "Filips Benoit"
<be***********@telenet.bewrote:

I would use a 1-liner: use the ShellExecute API with the Print verb.
That would be the equivalent of dropping the PDF file on the Default
Printer icon. Windows will invoke the registered app and tell it you
wanted to print that file.

-Tom.
>Dear All,
>
>All 3 codes, copied from internet, triggers error 429 : ActiveX
>component
>can't create object !
>No compile error.
>I have the reference set to Adobe Acrobat 7.0 Type Library
>I do not have the full version of Adobe Reader 7.0 !
>
>The final goal is to print a PDF-file from access after selecting the
>file
>in a browser.
>
>Please help!
>
>Filip
>
>------------------------------------------------------------------
>Private Sub Command0_Click()
>
Dim gApp As Acrobat.Acroapp
Dim gPDdoc As Acrobat.AcroPDDoc
>
Dim jso As Object
gApp = CreateObject("AcroExch.App")
gPDdoc = CreateObject("AcroExch.PDDoc")
If gPDdoc.Open("c:\adobe.pdf") Then
jso.gPDdoc.GetJSObject
jso.console.Show
jso.console.Clear
jso.console.println ("Hello, Adobe !")
gApp.Show
End If
>
>End Sub
>------------------------------------------------------------------
>Private Sub Command1_Click()
>
>Dim Acroapp As CAcroApp
>Dim avFile As CAcroAVDoc
Dim jso As Object
>'Start Acrobat in the background
>Set Acroapp = CreateObject("AcroExch.App")
>
>'Uncomment the following line if you want to watch the program run
>Acroapp.Show
>
>Set avFile = CreateObject("AcroExch.PDDoc") 'This is the code file
>
>'Open the already created code file
If avFile.Open("c:\adobe.pdf", "PDFfilip") Then
jso.gPDdoc.GetJSObject
jso.console.Show
jso.console.Clear
jso.console.println ("Hello, Adobe !")
Acroapp.Show
End If
>End Sub
>------------------------------------------------------------------
>Private Sub Command2_Click()
>
>Dim AcroExchApp As Object
>Dim AcroExchPDDoc As Object
>
>Set AcroExchApp = CreateObject("AcroExch.App")
>Set AcroExchPDDoc = CreateObject("AcroExch.PDDoc")
>
>' Show the Acrobat Exchange window
>AcroExchApp.Show
>
>AcroExchPDDoc.Open "c:\adobe.pdf"
>AcroExchPDDoc.PrintOut
>
>' Close the PDDoc
>AcroExchPDDoc.Close
>
>' Close Acrobat Exchange
>AcroExchApp.Exit
>
>End Sub
>------------------------------------------------------------------
>



Aug 4 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.