473,401 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Open/print PDF-file from Access

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
6 20417
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: CJ1 | last post by:
Hi, I'm building a .NET app that can print PDF files to a network printer without having Adobe Acrobat Reader installed, and get notified if the print is successful. Any suggestion? Thank you...
7
by: Alexander Wolff | last post by:
Hi Nobody know..how to print a existing .pdf file with c#. ( The idea is that the application prints de .pdf without open it with acrobat reader ) thanks!
2
by: Yuriy | last post by:
Hello! I need to print PDF Document by clicking a button on .aspx page. The PDF should be printed on client printer without displaing it on the window. I tried Process namespace but it doesn't...
5
by: Jim Ciotuszynski | last post by:
Does anybody know of a way to print a PDF on a clients browser without opening the activeX PDF viewer (that is if the client has it installed. TIA, Jim
0
by: chpadmamca | last post by:
Hi , I am working on JSF application .I need to open print popup window when i click on my JSF command link.How can i achieve this with javascript. Any help would be greatly appreciated as this...
0
by: sclinkenbeard | last post by:
I want to use a command button in Excel and have the VBA macro to open a PDF document. Does anyone know the VBA code to do so? It is easy opening word doc and another excel program but not sure how...
6
by: mistral | last post by:
what is correct way open a PDF document in new window use hyperlink? I want show images thumbnails linked with PDF files, when click on thumbnail, PDF will be opened in new window. Some of PDF...
1
by: Tim Sprout | last post by:
I want to call Page Setup to set default printer and page size and orientation before batch printing pdf's silently from WebBrowser controls. I can print silently using DDE (the NDde library) or...
2
by: rlu | last post by:
Is there a way to print a pdf document without opening it, if user just select the pdf files in the checkbox and click a button? I tried the following two methods, but both fail. 1. open a new...
13
by: MIkersson | last post by:
Hello everybody! I have a page index.html with a iframe that contains a photo "001.jpg" and what I need to do is to print the "001,pdf" version of that photo stored in a pdf/ folder HOW should...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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...

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.