Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to open Word file?

Status
Not open for further replies.

tb2007

Programmer
Apr 2, 2005
33
YU
I have code like this to open word file:

Set appWord = New Word.Application

appWord.Documents.Open Filename:=FileName, ReadOnly:=True, Revert:=True

appWord.Quit
Set appWord = Nothing


But when that word file is allready open in Word I get this error:

Component request pending
This action cannot be completed because the other application is busy.Choose "Swich to" to activate the busy application and correct the problem.

But after this error I cannot do nothing. I can only kill my application in Task manager.

Could somebody help me?

 
Try something like this - warning, just typed, not tested ...

[tt]on error resume next
set appWord = getobject("word.application")
if err.number <> 0 then
' no word instance
err.clear
set appWord = createobject("word.application")
if err.number <> 0 then
' word installed?
exit sub
end if
else
for each objDoc in appWord.documents
if objDoc.Name = strFileName then ' your filename
' document is alredy opened
end if
next objDoc
end if
on error goto <your error handler>[/tt]

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top