I'd like to write a VB script which closes a document in acroread and opens
another one. Is such a thing possible and if so where can I find a tutorial,
sample script...

Thanks
Lutz

Re: Control Acroread by Tom

Tom
Sun Dec 21 08:24:40 CST 2003


"Lutz Niggl" <lutz.niggl@tecan.com> wrote in message
news:bs3qhg$968qe$1@ID-172978.news.uni-berlin.de...
> I'd like to write a VB script which closes a document in acroread and opens
> another one. Is such a thing possible and if so where can I find a tutorial,
> sample script...
>
> Thanks
> Lutz
>

Hi
here's a quick sample. A search on google should show other examples.
http://www.google.com/search?q=createobject+acroexch

Set oApp = CreateObject("AcroExch.App")
oApp.Show

Set oDoc = CreateObject("AcroExch.AVDoc")

oDoc.Open "c:\myfile.pdf", "My Document"

' or Set oDoc = oApp.GetActiveDoc

WScript.Sleep 2000

oDoc.Close True
oApp.CloseAllDocs
oApp.Exit





Re: Control Acroread by Torgeir

Torgeir
Sun Dec 21 10:52:37 CST 2003

Lutz Niggl wrote:

> I'd like to write a VB script which closes a document in acroread and opens
> another one. Is such a thing possible and if so where can I find a tutorial,
> sample script...

Hi

Acrobat Reader can't be automated from a "pure" vbscript (well, in a crude way
it can, see code below), the Acrobat Reader has to be hosted in a container
window like a VB form or an IE window.

This Web page demonstrates how to use an IE instance from a vbscript to control
AcroRead:
http://www.borncity.de/WSHBazaar/News5.htm



Here is the crude way (AcroRd32.exe is terminated between each launch):


Set oWmi = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\.\root\cimv2")


Set oShell = CreateObject("Wscript.Shell")

sPdfFile = "F:\PC_kjoep4.pdf"
' /s is means no splash screen.
oShell.Run "%comspec% /c start /wait AcroRd32.exe /s """ _
& sPdfFile & """", 0, True

TerminateAcroRd32

sPdfFile = "F:\Opslocks_in_Windows_2000_XP.pdf"

oShell.Run "%comspec% /c start /wait AcroRd32.exe /s """ _
& sPdfFile & """", 0, True


Sub TerminateAcroRd32
Set colProcessList = oWmi.ExecQuery _
("Select * from Win32_Process Where Name = 'AcroRd32.exe'")
For Each oProcess in colProcessList
oProcess.Terminate()
Next
End Sub





--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter



Re: Control Acroread by Torgeir

Torgeir
Sun Dec 21 10:53:46 CST 2003

Tom Brown wrote:

> here's a quick sample. A search on google should show other examples.
> http://www.google.com/search?q=createobject+acroexch
>
> Set oApp = CreateObject("AcroExch.App")
> oApp.Show
>
> Set oDoc = CreateObject("AcroExch.AVDoc")
>
> oDoc.Open "c:\myfile.pdf", "My Document"
>
> ' or Set oDoc = oApp.GetActiveDoc
>
> WScript.Sleep 2000
>
> oDoc.Close True
> oApp.CloseAllDocs
> oApp.Exit

Hi

I would think you will need the full Acrobat installed and not just Acrobat Reader
to get this to work...



--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page Scripting
Guide: http://www.microsoft.com/technet/scriptcenter



Re: Control Acroread by Ross

Ross
Sun Dec 21 22:53:17 CST 2003

"Torgeir Bakken (MVP)" <Torgeir.Bakken-spam@hydro.com> wrote in
news:3FE5CFD5.BB318208@hydro.com:

> Here is the crude way (AcroRd32.exe is terminated between each launch):
>

What about SendKeys or AutoIt?

Re: Control Acroread by Torgeir

Torgeir
Sun Dec 21 23:35:49 CST 2003

Ross Presser wrote:

> Torgeir Bakken (MVP) wrote:
>
> > Here is the crude way (AcroRd32.exe is terminated between each launch):
> >
>
> What about SendKeys or AutoIt?

Yes, that is an alternative, but if your Sendkeys comes out of sync "funny"
things can happen ;-) Using AutoIt (or AutoItX) better window handling makes
it a bit better, but it isn't exactly bulletproof still...


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter



Re: Control Acroread by Reinhard

Reinhard
Mon Dec 22 14:42:10 CST 2003

I would prefer Sendkey(/AutoITX). But at least there a 2
other, more workfull, options.

One would be to use DDE. You don't can do it direct with
VBS. But I think you can write a regkey (file-association)
and then execute the verb (invoke verb).

Another possibility comes from Adobe by themself. I thing
thoughted for other thinks but works fine. You can write a
FDF-file (=>plain text file with specific structure). With
a FDF file you can send Adobe-Java Script to the Reader.
CloseDoc() is also supported from Reader.

HTH, Reinhard