Error: Object Required: 'documents.add' Code: 800A01A8 On Windows 7 Office 2010

I'm getting the error below when executing the below code on Windows 7 64bit Office 2010 machines at my company.

Script: word.vbs
Line 6 Char 1
Error: Object Required: 'documents.add' 
Code: 800A01A8
Source: MS VBScript runtime error

Open in new window

dim word
set word=createobject("Word.Application")

dim document
set document=word.documents.add

Open in new window

The code was given to me for testing purposes by a 3rd party application support company. It should just open a blank document in Word.

I've tried this on many different machines running a variety of Windows 7 64bit Office 2010 machines and get a seemly random mix of errors and successes. I have tried fully enabling macros and lowering security.

On one machine the script will return the error if Word is already open but will work successfully if not.

Does anyone know of any prevailing conditions or settings which will determine whether this will work?
Who is Participating?
There is a site which details similar issues - the fix for them was a MS hotfix.

Can you try the code below to see if that works for your toubled machines?
on error resume next

Dim word
Dim document
Dim isWorking
Dim escapeFromLoop

set word = createobject("Word.Application")

isWorking = false
escapeFromLoop = 0
	escapeFromLoop = escapeFromLoop + 1
	set document = word.documents.add()
	if err.number <> 0 then
		wscript.sleep 500
		isWorking = true
	end if
	if escapeFromLoop = 10 then
		wscript.echo "Error adding Word object"
	end if
loop until isWorking = true

Open in new window

Try not calling the variable 'word'
Call it objWord or wordApp or something.
support01Author Commented:
Thanks rejoinder, haven't tried hotfix but new line of code works a treat

dim wordapp
set wordapp=createobject("Word.Application")
Wscript.Sleep 500
dim document
set document=wordapp.documents.add

Open in new window

Glad that helped and thanks for the points :-)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.