473,835 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.AcroPDD oc

Dim jso As Object
gApp = CreateObject("A croExch.App")
gPDdoc = CreateObject("A croExch.PDDoc")
If gPDdoc.Open("c: \adobe.pdf") Then
jso.gPDdoc.GetJ SObject
jso.console.Sho w
jso.console.Cle ar
jso.console.pri ntln ("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("A croExch.App")

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

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

'Open the already created code file
If avFile.Open("c: \adobe.pdf", "PDFfilip") Then
jso.gPDdoc.GetJ SObject
jso.console.Sho w
jso.console.Cle ar
jso.console.pri ntln ("Hello, Adobe !")
Acroapp.Show
End If
End Sub
------------------------------------------------------------------
Private Sub Command2_Click( )

Dim AcroExchApp As Object
Dim AcroExchPDDoc As Object

Set AcroExchApp = CreateObject("A croExch.App")
Set AcroExchPDDoc = CreateObject("A croExch.PDDoc")

' Show the Acrobat Exchange window
AcroExchApp.Sho w

AcroExchPDDoc.O pen "c:\adobe.p df"
AcroExchPDDoc.P rintOut

' Close the PDDoc
AcroExchPDDoc.C lose

' Close Acrobat Exchange
AcroExchApp.Exi t

End Sub
------------------------------------------------------------------
Aug 3 '07 #1
6 20456
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.AcroPDD oc

Dim jso As Object
gApp = CreateObject("A croExch.App")
gPDdoc = CreateObject("A croExch.PDDoc")
If gPDdoc.Open("c: \adobe.pdf") Then
jso.gPDdoc.GetJ SObject
jso.console.Sho w
jso.console.Cle ar
jso.console.pri ntln ("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("A croExch.App")

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

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

'Open the already created code file
If avFile.Open("c: \adobe.pdf", "PDFfilip") Then
jso.gPDdoc.GetJ SObject
jso.console.Sho w
jso.console.Cle ar
jso.console.pri ntln ("Hello, Adobe !")
Acroapp.Show
End If
End Sub
------------------------------------------------------------------
Private Sub Command2_Click( )

Dim AcroExchApp As Object
Dim AcroExchPDDoc As Object

Set AcroExchApp = CreateObject("A croExch.App")
Set AcroExchPDDoc = CreateObject("A croExch.PDDoc")

' Show the Acrobat Exchange window
AcroExchApp.Sh ow

AcroExchPDDoc. Open "c:\adobe.p df"
AcroExchPDDoc. PrintOut

' Close the PDDoc
AcroExchPDDoc. Close

' Close Acrobat Exchange
AcroExchApp.Ex it

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.c om...
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.AcroPDD oc

Dim jso As Object
gApp = CreateObject("A croExch.App")
gPDdoc = CreateObject("A croExch.PDDoc")
If gPDdoc.Open("c: \adobe.pdf") Then
jso.gPDdoc.GetJ SObject
jso.console.Sho w
jso.console.Cle ar
jso.console.pri ntln ("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("A croExch.App")

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

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

'Open the already created code file
If avFile.Open("c: \adobe.pdf", "PDFfilip") Then
jso.gPDdoc.GetJ SObject
jso.console.Sho w
jso.console.Cle ar
jso.console.pri ntln ("Hello, Adobe !")
Acroapp.Show
End If
End Sub
------------------------------------------------------------------
Private Sub Command2_Click( )

Dim AcroExchApp As Object
Dim AcroExchPDDoc As Object

Set AcroExchApp = CreateObject("A croExch.App")
Set AcroExchPDDoc = CreateObject("A croExch.PDDoc")

' Show the Acrobat Exchange window
AcroExchApp.S how

AcroExchPDDoc .Open "c:\adobe.p df"
AcroExchPDDoc .PrintOut

' Close the PDDoc
AcroExchPDDoc .Close

' Close Acrobat Exchange
AcroExchApp.E xit

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.bewrot e:

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.AcroPDD oc

Dim jso As Object
gApp = CreateObject("A croExch.App")
gPDdoc = CreateObject("A croExch.PDDoc")
If gPDdoc.Open("c: \adobe.pdf") Then
jso.gPDdoc.GetJ SObject
jso.console.Sho w
jso.console.Cle ar
jso.console.pri ntln ("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("A croExch.App")

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

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

'Open the already created code file
If avFile.Open("c: \adobe.pdf", "PDFfilip") Then
jso.gPDdoc.GetJ SObject
jso.console.Sho w
jso.console.Cle ar
jso.console.pri ntln ("Hello, Adobe !")
Acroapp.Show
End If
End Sub
------------------------------------------------------------------
Private Sub Command2_Click( )

Dim AcroExchApp As Object
Dim AcroExchPDDoc As Object

Set AcroExchApp = CreateObject("A croExch.App")
Set AcroExchPDDoc = CreateObject("A croExch.PDDoc")

' Show the Acrobat Exchange window
AcroExchApp. Show

AcroExchPDDo c.Open "c:\adobe.p df"
AcroExchPDDo c.PrintOut

' Close the PDDoc
AcroExchPDDo c.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 WaitForSingleOb ject Lib "kernel32" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long

Private Declare Function FindWindow Lib "user32" _
Alias "FindWindow A" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Private Declare Function PostMessage Lib "user32" _
Alias "PostMessag eA" _
(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 GetWindowThread ProcessId 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.p df", 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(vbNu llString, "Adobe Reader-[adobe.pdf]")
If hWindow = 0 Then hWindow = FindWindow(vbNu llString, "Adobe
Reader - [adobe.pdf]")
If hWindow = 0 Then hWindow = FindWindow(vbNu llString, "Adobe
Reader")
If hWindow = 0 Then hWindow = FindWindow(vbNu llString, "Adobe
Acrobat")
If hWindow = 0 Then hWindow = FindWindow("AVL _AVPopup", "")
If iLoop 50 Then Exit Do
Loop

MsgBox hWindow

hThread = GetWindowThread ProcessId(hWind ow, lProcessId)
hProcess = OpenProcess(SYN CHRONIZE, 0&, lProcessId)
lngReturnValue = PostMessage(hWi ndow, WM_CLOSE, 0&, 0&)
lngResult = WaitForSingleOb ject(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.c om...
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.bewro te:

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.AcroPDD oc

Dim jso As Object
gApp = CreateObject("A croExch.App")
gPDdoc = CreateObject("A croExch.PDDoc")
If gPDdoc.Open("c: \adobe.pdf") Then
jso.gPDdoc.GetJ SObject
jso.console.Sho w
jso.console.Cle ar
jso.console.pri ntln ("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("A croExch.App")

'Uncommen t the following line if you want to watch the program run
Acroapp.Sho w

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

'Open the already created code file
If avFile.Open("c: \adobe.pdf", "PDFfilip") Then
jso.gPDdoc.GetJ SObject
jso.console.Sho w
jso.console.Cle ar
jso.console.pri ntln ("Hello, Adobe !")
Acroapp.Show
End If
End Sub
------------------------------------------------------------------
Private Sub Command2_Click( )

Dim AcroExchApp As Object
Dim AcroExchPDDoc As Object

Set AcroExchApp = CreateObject("A croExch.App")
Set AcroExchPDDoc = CreateObject("A croExch.PDDoc")

' Show the Acrobat Exchange window
AcroExchApp .Show

AcroExchPDD oc.Open "c:\adobe.p df"
AcroExchPDD oc.PrintOut

' Close the PDDoc
AcroExchPDD oc.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******** *************@p hobos.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 WaitForSingleOb ject Lib "kernel32" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long

Private Declare Function FindWindow Lib "user32" _
Alias "FindWindow A" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Private Declare Function PostMessage Lib "user32" _
Alias "PostMessag eA" _
(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 GetWindowThread ProcessId 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.p df", 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(vbNu llString, "Adobe Reader-[adobe.pdf]")
If hWindow = 0 Then hWindow = FindWindow(vbNu llString, "Adobe
Reader - [adobe.pdf]")
If hWindow = 0 Then hWindow = FindWindow(vbNu llString, "Adobe
Reader")
If hWindow = 0 Then hWindow = FindWindow(vbNu llString, "Adobe
Acrobat")
If hWindow = 0 Then hWindow = FindWindow("AVL _AVPopup", "")
If iLoop 50 Then Exit Do
Loop

MsgBox hWindow

hThread = GetWindowThread ProcessId(hWind ow, lProcessId)
hProcess = OpenProcess(SYN CHRONIZE, 0&, lProcessId)
lngReturnValue = PostMessage(hWi ndow, WM_CLOSE, 0&, 0&)
lngResult = WaitForSingleOb ject(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.c om...
>On Fri, 03 Aug 2007 15:54:22 GMT, "Filips Benoit"
<be*********** @telenet.bewrot e:

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***** *************** ************@4a x.com...
On Fri, 03 Aug 2007 10:43:28 GMT, "Filips Benoit"
<be********* **@telenet.bewr ote:

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
>componen t
>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.AcroPDD oc
>
Dim jso As Object
gApp = CreateObject("A croExch.App")
gPDdoc = CreateObject("A croExch.PDDoc")
If gPDdoc.Open("c: \adobe.pdf") Then
jso.gPDdoc.GetJ SObject
jso.console.Sho w
jso.console.Cle ar
jso.console.pri ntln ("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("A croExch.App")
>
>'Uncomme nt the following line if you want to watch the program run
>Acroapp.Sh ow
>
>Set avFile = CreateObject("A croExch.PDDoc") 'This is the code file
>
>'Open the already created code file
If avFile.Open("c: \adobe.pdf", "PDFfilip") Then
jso.gPDdoc.GetJ SObject
jso.console.Sho w
jso.console.Cle ar
jso.console.pri ntln ("Hello, Adobe !")
Acroapp.Show
End If
>End Sub
>------------------------------------------------------------------
>Private Sub Command2_Click( )
>
>Dim AcroExchApp As Object
>Dim AcroExchPDDoc As Object
>
>Set AcroExchApp = CreateObject("A croExch.App")
>Set AcroExchPDDoc = CreateObject("A croExch.PDDoc")
>
>' Show the Acrobat Exchange window
>AcroExchAp p.Show
>
>AcroExchPD Doc.Open "c:\adobe.p df"
>AcroExchPD Doc.PrintOut
>
>' Close the PDDoc
>AcroExchPD Doc.Close
>
>' Close Acrobat Exchange
>AcroExchAp p.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.fol lowhyperlink "filename.p df"
"Filips Benoit" <be***********@ telenet.bewrote in message
news:5a******** *************@p hobos.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 WaitForSingleOb ject Lib "kernel32" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long

Private Declare Function FindWindow Lib "user32" _
Alias "FindWindow A" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Private Declare Function PostMessage Lib "user32" _
Alias "PostMessag eA" _
(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 GetWindowThread ProcessId 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.p df", 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(vbNu llString, "Adobe Reader-[adobe.pdf]")
If hWindow = 0 Then hWindow = FindWindow(vbNu llString, "Adobe
Reader - [adobe.pdf]")
If hWindow = 0 Then hWindow = FindWindow(vbNu llString, "Adobe
Reader")
If hWindow = 0 Then hWindow = FindWindow(vbNu llString, "Adobe
Acrobat")
If hWindow = 0 Then hWindow = FindWindow("AVL _AVPopup", "")
If iLoop 50 Then Exit Do
Loop

MsgBox hWindow

hThread = GetWindowThread ProcessId(hWind ow, lProcessId)
hProcess = OpenProcess(SYN CHRONIZE, 0&, lProcessId)
lngReturnValue = PostMessage(hWi ndow, WM_CLOSE, 0&, 0&)
lngResult = WaitForSingleOb ject(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.c om...
>On Fri, 03 Aug 2007 15:54:22 GMT, "Filips Benoit"
<be*********** @telenet.bewrot e:

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***** *************** ************@4a x.com...
On Fri, 03 Aug 2007 10:43:28 GMT, "Filips Benoit"
<be********* **@telenet.bewr ote:

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
>componen t
>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.AcroPDD oc
>
Dim jso As Object
gApp = CreateObject("A croExch.App")
gPDdoc = CreateObject("A croExch.PDDoc")
If gPDdoc.Open("c: \adobe.pdf") Then
jso.gPDdoc.GetJ SObject
jso.console.Sho w
jso.console.Cle ar
jso.console.pri ntln ("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("A croExch.App")
>
>'Uncomme nt the following line if you want to watch the program run
>Acroapp.Sh ow
>
>Set avFile = CreateObject("A croExch.PDDoc") 'This is the code file
>
>'Open the already created code file
If avFile.Open("c: \adobe.pdf", "PDFfilip") Then
jso.gPDdoc.GetJ SObject
jso.console.Sho w
jso.console.Cle ar
jso.console.pri ntln ("Hello, Adobe !")
Acroapp.Show
End If
>End Sub
>------------------------------------------------------------------
>Private Sub Command2_Click( )
>
>Dim AcroExchApp As Object
>Dim AcroExchPDDoc As Object
>
>Set AcroExchApp = CreateObject("A croExch.App")
>Set AcroExchPDDoc = CreateObject("A croExch.PDDoc")
>
>' Show the Acrobat Exchange window
>AcroExchAp p.Show
>
>AcroExchPD Doc.Open "c:\adobe.p df"
>AcroExchPD Doc.PrintOut
>
>' Close the PDDoc
>AcroExchPD Doc.Close
>
>' Close Acrobat Exchange
>AcroExchAp p.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
1263
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 very much!
7
7064
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
1952
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 work. Please, help! Thank you.
5
1850
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
1399
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 is very urgent need. Thanks, Padma.
0
1984
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 to do so with a pdf document. Do I need to tell the macro to open Adobe first? Any assistance is helpful. Thank you.
6
18239
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 files are in the same web server, other are in a remote location. Any help will be appreciated.
1
12627
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 Adobe Interapplication Communication (IAC) DotNet API. There is no Adobe DDE command or IAC API for Page Setup. I don't see a print silent method for the WebBrowser control. I can get a Page Setup dialog to appear by using the code below, but the...
2
4234
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 window: win=window.open("","","width=5 height=5"); win.blur(); win.document.location="http://www.mydomain.com/mydoc.pdf"; win.print();
13
4791
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 I do that with JavaScript? Im not a programmer I just need to get some rules then I can make it works. Thank you verymuch!
0
9802
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10807
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10517
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10230
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9343
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6961
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5802
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4430
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3086
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.