I have a on close event macro that adjust some tables in a word document when
it is closed for the first time.
How do I delete or disable the macro during the first document closing?
Is it possible to delete the macro itself as the last command in the macro?
Regards
Frank Krogh
Greg Maxey - 05 Oct 2006 12:50 GMT
Frank,
You could set a document variable when the document is first closed and
then use it to determine if it has been closed previously and bypass
the remaing code:
Sub Document_Close()
On Error GoTo Handler
If ActiveDocument.Variables("Flag").Value = "Closed" Then
Exit Sub
Else
ActiveDocument.Variables("Flag").Value = "Closed"
MsgBox "Do your deed"
End If
Exit Sub
Handler:
ActiveDocument.Variables("Flag").Value = " "
Resume
End Sub
AFAIK you can't delete the macro in the manner you suggest.
> I have a on close event macro that adjust some tables in a word document when
> it is closed for the first time.
[quoted text clipped - 6 lines]
>
> Frank Krogh
Tony Jollans - 05 Oct 2006 19:12 GMT
It _is_ possible (subject to the user allowing it in recent versions of
Word) to have self deleting code but it, in this case at least, it rather
begs the question as to how the code got into the document in the first
place.
--
Enjoy,
Tony
> I have a on close event macro that adjust some tables in a word document when
> it is closed for the first time.
[quoted text clipped - 6 lines]
>
> Frank Krogh