This follows on from thread1251-924215
I am using VFP8 but haven't really got to grips with TRY...CATCH...FINALLY (TCF).
Here is a snippet of code (there is more code before and after this bit):
The line oDoc = oWord.Documents.Open(THIS.txtLetter.Value) sometimes causes an error.
To implement TCF, should I:
[ol][li]put the whole IF...ENDIF inside the TRY and, if it caused an error, set a variable to FALSE and test that variable in the line beyond the TRY...ENDTRY to see if the rest of the code should execute[/li]
[li]put just the offending line inside the TCF structure[/li]
[li]put the preceding lines and all the lines that follow inside the TCF structure?[/li][/ol]
Thanks,
Stewart
I am using VFP8 but haven't really got to grips with TRY...CATCH...FINALLY (TCF).
Here is a snippet of code (there is more code before and after this bit):
Code:
IF NOT TextCopied
oWord = CREATEOBJECT("Word.Application")
WAIT WINDOW NOWAIT "Mailmerge - copying text"
oDoc = oWord.Documents.Open(THIS.txtLetter.Value)
oRange = oDoc.Range()
oRange.Copy()
CopiedText = _CLIPTEXT
&& ....assign the clipboard contents to a variable
&& to prevent problems should the user copy
&& some text to the clipboard in another application
TextCopied = .T.
ENDIF
The line oDoc = oWord.Documents.Open(THIS.txtLetter.Value) sometimes causes an error.
To implement TCF, should I:
[ol][li]put the whole IF...ENDIF inside the TRY and, if it caused an error, set a variable to FALSE and test that variable in the line beyond the TRY...ENDTRY to see if the rest of the code should execute[/li]
[li]put just the offending line inside the TCF structure[/li]
[li]put the preceding lines and all the lines that follow inside the TCF structure?[/li][/ol]
Thanks,
Stewart