vbscript not working in Office 2003 on Windows 2000

G

GeorgeMar

I am using the code (below) that I found on this site and it works well with
Office 2002 on win 98 but won't work in Office 2003 on Win 2000. This script
is created and run from a Access VBA.

It would appear that this line - "While fso.AppActivate(""Microsoft
Outlook"")=FALSE", - is never set to TRUE

Any Help please
George

arr = Array( _
"Set fso=CreateObject(""WScript.Shell"")", _
"While fso.AppActivate(""Microsoft Outlook"")=FALSE", _
" wscript.sleep 7000", _
"Wend", _
"fso.SendKeys ""a"",True", _
"fso.SendKeys ""{TAB}"",True", _
"fso.SendKeys ""{Enter}"",True", _
"Set fso=Nothing" _
)
Set fso = CreateObject("Scripting.FilesystemObject")
Set fsofile = fso.CreateTextFile("bypass.vbs")
For i = LBound(arr) To UBound(arr)
fsofile.WriteLine arr(i)
Next
fsofile.Close
' Open Scripting shell and Run bypass file
Set WSHshell = CreateObject("Wscript.Shell")
WSHshell.Run ("bypass.vbs")
Set WSHshell = Nothing
 
J

John Nurick

Hi George,

Could this be because of (a) security settings and/or antivirus settings
on the Windows 2000 machine or (b) security settings in Office 2003?

In any case, the UI changes between Outlook 2002 and Outlook 2003 make
SendKeys an even more risky business than usual. It would be better to
work with the Outlook object model from within your VBA code: that way
you would be able to trap any errors as you opened Outlook.
 
G

GeorgeMar

Thank you John

I have found the problem. In 2002 the window is called "Microsoft Outlook"
and 2003 it is called "Microsoft Office Outlook"

George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top