Link to home
Start Free TrialLog in
Avatar of dkjean
dkjean

asked on

Check if word is installed vb.net

HI,
This script failed on computers with and with out word installed.


Set objNetwork = CreateObject("Wscript.Network")
Set objSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & objSysInfo.UserName)
Set objUnder = GetObject(objUser.Parent)
Set objHoved = GetObject(objUnder.Parent)

strUser = objUser.Get("sAMAccountName")

If Not Type (objword) = "Nothing" Then
Set objWord = CreateObject("Word.Application")

objWord.UserName = objUser.givenName & " " & objUser.SN
objWord.UserInitials = objUser.sAMAccountName
objLogFile.WriteLine "Jobbet er fuldført: " & "Office initialer er rettet."
objWord.Quit
Else
objLogFile.WriteLine "Der blev ikke fundet Word:" & "Ingen rettelser."
End If
Avatar of AmitKB
AmitKB
Flag of India image

I have modifed the code please take a look.
You will error at the line where "objLogFile" is there becuase it is not created.
Set objNetwork = CreateObject("Wscript.Network")
Set objSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & objSysInfo.UserName)
Set objUnder = GetObject(objUser.Parent)
Set objHoved = GetObject(objUnder.Parent)

strUser = objUser.Get("sAMAccountName")


Set objWord = CreateObject("Word.Application")

If Not objword Is Nothing Then
objWord.UserName = objUser.givenName & " " & objUser.SN
objWord.UserInitials = objUser.sAMAccountName
objLogFile.WriteLine "Jobbet er fuldført: " & "Office initialer er rettet."
objWord.Quit
Else
objLogFile.WriteLine "Der blev ikke fundet Word:" & "Ingen rettelser."
End If

Open in new window

Avatar of dkjean
dkjean

ASKER

I get a error in line "set objword = CreateObject("word.Application")
On a machine were there is no word installed.
Yes about the log :-)
ASKER CERTIFIED SOLUTION
Avatar of AmitKB
AmitKB
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dkjean

ASKER

Thanks a lot
I did'net work on the machines without word.
But I have use your script with the string.... On error Resume Next
It works.
You can simulate as Word (or any other application not installed) not installed by using following code:
Set objWord = CreateObject("NoWord.Application")

Open in new window