Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Open Word read/only, prevent save as, release variable
Message
 
 
To
30/07/2007 09:20:54
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
01244081
Message ID:
01244539
Views:
24
>>>I tried
>>>
>>>if vartype(loWord.visible) = 'U'
>>>   loWord = createobject("Word.Application")
>>>endif
>>>
>>>
>>>I get an error message that "RPC server is unavailable". How do I check if the server is available?
>>>
>>
>>Strange error and strange check. Did you first check that loWord is an object?
>
>I tried that first and it returned 'O'
>>
>>Always wrap createobject in try/catch block.
>
>I have not used try/catch blocks yet. How would I do that?

I was thinking meanwhile that if you already have loWord object you would not probably be able to create another instance of it (need to test).

Anyway, here is what you can do:
try
  loWord = createobject('Word.Application')
  * proceed with the rest of the code

catch to loException
  * Something went wrong, analyze the reason and loException object
finally
  if vartype(m.loWord) = 'O' && Object was created
     loWord.Close(0)
     loWord.Quit
     loWord = null
  endif
endtry
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform