Hello NG,
I have a macro that is associated with a check box from the "forms" tools,
and if it is clicked then the "Run macro on Entry" of the check box.
If someone changes their mind and deselects chbox and then selects it again
the macro runs again.
How can I get the macro to only run once.
I've tried to create a flag and set it to 1 if the macro has already run,
but that doesn't seem to work for me,
any suggestions.
James
'Code begins here============
Private Sub Document_Open()
Dim wdFlag As Integer
wdFlag = 0
End Sub
Sub Color()
'
' Color Macro
' Created: Nov. 9th 2004
' Author: James
' Purpose: Informs customer of printer purchase options
'
If wdFlag = 0 Then
Selection.EndKey Unit:=wdStory
Selection.Font.Color = wdColorDarkBlue
Selection.TypeText Text:= _
"We can help you purchase an inkjet printer at a substantial "
Selection.TypeText Text:="discount!" & Chr(11) & _
"Please call Liz at 555-1234 for more information!"
wdFlag = 1
Else
Exit Sub
End If
End Sub
'Code ends here===========
Joost Verdaasdonk - 13 Nov 2004 20:52 GMT
Hi,
Put something in the document you can delete after macro
execution! e.g.: Bookmark, doc variable, etc....
Little Example for you're code: (using bookmark)
Sub Test()
If ActiveDocument.Bookmarks.Exists("bmCheck") Then
'Do you're stuff
ActiveDocument.Bookmarks("bmCheck").Delete
End If
End Sub
Enjoy,
Groetjes,
Joost Verdaasdonk
James - 15 Nov 2004 02:13 GMT
Joost Verdaasdonk,
Thanks for the help, I am going to put this to work first thing Monday
morning
James
> Hi,
>
[quoted text clipped - 12 lines]
> Groetjes,
> Joost Verdaasdonk
Gal Zilberman - 15 Nov 2004 10:58 GMT
Or you can just add a global variable
Example
private Flag as boolean
Sub Test()
if Flag =True then
' Don't run the macro
else
'Do what you want
Flag =True
end if
End Sub
> Joost Verdaasdonk,
> Thanks for the help, I am going to put this to work first thing Monday
[quoted text clipped - 17 lines]
>> Groetjes,
>> Joost Verdaasdonk