VB script outlook and filesite

I have this script where it check to see if outlook is installed then it doesn't do anything.. But if outlook hasn't been run it then runs outlook to create a profile then closes reopenes then adds in an outlook.prf file closes outlook then adds in a third party application.

The third party application needs outlook to be installed first before being add in.

The problem I have is on line 41
Error is Argument not optional wscript.getobject

Can anyone help... Sorry I'm only new at scripting.

Cheers
Dim objNetwork, strUserName, WshShell, lServer, strDirectory, objFSO
Dim objShell, objOutlook, objGetOutlook, sOutlookVersion 
 
' Create Outlook object and Shell object 
Set objOutlook = CreateObject("Outlook.Application")
Set objGetOutlook = GetObject(, "Outlook.Application")
Set objShell = CreateObject("WScript.Shell") 
 
'Get logged on user's name
Set objNetwork = WScript.CreateObject("WScript.Network")
strUserName = objNetwork.UserName
 
'Get user's logon server
Set WshShell = WScript.CreateObject("WScript.Shell")
lserver = WshShell.ExpandEnvironmentStrings("%logonserver%")
 
'See if the user needs Outlook configured
strDirectory = "C:\Documents and Settings\" & strusername & "\Application Data\Microsoft\Outlook"
 
' Create the various objects
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
' Determine outlook version
If objOutlook.Version >= "11.0" And objOutlook.version <= "11.1" Then 
  sOutlookVersion = "11" 
End If 
 
' Import PRF
If Not objFSO.FolderExists(strDirectory) Then
  Set oShell = CreateObject("WScript.Shell")
  oShell.Run Chr(34) & "C:\Program Files\Microsoft Office\OFFICE" & sOutlookVersion & "\Outlook.exe" & Chr(34) & " /importprf \\servername\IT\Outlook\OutlookProfile.PRF", 1, False
End If
 
' Sleep for a second to give Outlook enough time to create the profile before we kill it 
 
WScript.Sleep 5000 'sleep for 5 miliseconds
 
' Close Outlook , so we can register FileSite
 
Dim Outlook 'As Outlook.Application 
Set Outlook = Wscript.GetObject (, "Outlook.Application") 
If objGetOutlook Is Nothing Then 
'no need to do anything, Outlook is not running 
Else
  'Outlook running
  objGetOutlook.Session.Logoff
  objGetOutlook.Quit
End If 
Set objoutlook = Nothing
 
' Sleep for a second to give Outlook enough time to close before we register FileSite
 
WScript.Sleep 20000 'sleep for 4 seconds
 
objshell.run("cmd /c ""C:\Program Files\Interwoven\WorkSite\addiman.exe"" servername")

Open in new window

gladminsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

wmeerzaCommented:
change line 41 to:
Set Outlook = Wscript.GetObject ("", "Outlook.Application")
0
gladminsAuthor Commented:
Thank you wmeerza.. That fixed it..

But now I'm getting an error on line 42 saying object required
0
wmeerzaCommented:
strange, although i did see a problem on line 6, change it to:
Set objGetOutlook = GetObject("", "Outlook.Application")

if you want to debug it try checking the variables as they are set e.g. put a wscript.echo variablename after the line where it gets set to confirm things are happening where you want it.

e.g. after line 41 put in:
Wscript.Echo objGetOutlook

this will then display the value.

I would also check what you are trying to achive from line 41 onwards, it's confusing me a bit!
I have tested it and it closes outlook.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gladminsAuthor Commented:
Thank you mate.. You have point me in the right direction I just need top fix up the last part.. Basically after outlook has opened and closed and imported in the outlook.prf file is to close again run a third party addin for outlook (its our document management system) then open outlook.
0
wmeerzaCommented:
no problem, sounds like your nearly there, as you said, a bit of a tidy up and things should start to look good.
Cheers.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.