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