>>>>I've got a single global error-handling routine. However, I'd like to
>>>>include a command in it that might generate an error. Elsewhere, the
>>>>following works:
>>>>lcOldOnError=ON("ERROR")
>>>>ON ERROR * && Do nothing
>>>>loWord.Visible=.T. && This will fail if loWord doesn't exist or
>>>>the link to MSWord is no longer current
>>>>ON ERROR &lcOldOnError
>[ snip; I suggested: ]
>>>IF Type("loWord") = "O"
>>> loWord.Visible=.T.
>>>ENDIF
>>(Sorry about delay - My ISP has only just started delivering news after
>>a week's gap!!)
>>This unfortunately will not work in all cases: it is quite possible for
>>VFP to return TYPE("loWord") as O, but MSWord has shut down (or the link
>>has been broken).
>>Is there any way to test if the link is still *live* and only then set
>>Visible to .T.?
>Well you can always use your old approach, just do it _outside_ of ON ERROR
>routine, e.g.,
>oldonerr = ON("ERROR")
>wordalive = .T.
>ON ERROR wordalive = .F.
>loWord.Visible = .T.
>ON ERROR &oldonerr
>and then in your main ON ERROR routine analyze the value of wordalive variable.
This unfortunately does not directly solve my problem, because the whole
point is that I want it *inside* the error routine: i.e. if there is
ever an error, and a word document is still lurking invisibly behind the
scenes, then make it visible.
However, your suggestion gave me the 'third way': use a separate
'wordalive' variable that is set to to true whenever I start a new word
object, and release it whenever I make that word object visible. Then,
when I have an error, just test the 'wordalive' variable, and set
loWord.Visible if appropriate.
So thanks, your suggestion got me there in the end!
--
Ben Hambidge