G
Greg Maxey
I discussed this issue in a very long post yesterday as a sidebar and
thought it better to simplify my observations and question here as a
dedicated post. I will sacrifice my second born child as repentence
for double posting.
This code works as expected:
Sub Test()
Dim oDoc As Word.Document
Dim oRng As Word.Range
Set oDoc = Documents.Add
Set oRng = oDoc.Range
oRng.Text = "Test"
MsgBox oDoc.Range
oDoc.Close wdDoNotSaveChanges
End Sub
I can call the code above using this code and it still works as
expected:
Sub OnExitFormField()
Test
End Sub
However, if I assign OnExitFormField () to the exit event of a
protected formfield then when I tab out of that formfield a Run-Time
Error 4198 "Command Failed" occurs on this line:
oDoc.Close wdDoNotSaveChanges
But, if I put a break in the code at that line and then tab out of the
field the editor runs to that line and stops and I can manually step
through the remainder of the code without error.
Can anyone explain why this happens? Thanks.
thought it better to simplify my observations and question here as a
dedicated post. I will sacrifice my second born child as repentence
for double posting.
This code works as expected:
Sub Test()
Dim oDoc As Word.Document
Dim oRng As Word.Range
Set oDoc = Documents.Add
Set oRng = oDoc.Range
oRng.Text = "Test"
MsgBox oDoc.Range
oDoc.Close wdDoNotSaveChanges
End Sub
I can call the code above using this code and it still works as
expected:
Sub OnExitFormField()
Test
End Sub
However, if I assign OnExitFormField () to the exit event of a
protected formfield then when I tab out of that formfield a Run-Time
Error 4198 "Command Failed" occurs on this line:
oDoc.Close wdDoNotSaveChanges
But, if I put a break in the code at that line and then tab out of the
field the editor runs to that line and stops and I can manually step
through the remainder of the code without error.
Can anyone explain why this happens? Thanks.