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===========

Run once macro by Joost

Joost
Sat Nov 13 14:52:59 CST 2004

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

Re: Run once macro by James

James
Sun Nov 14 20:13:30 CST 2004

Joost Verdaasdonk,
Thanks for the help, I am going to put this to work first thing Monday
morning
James


"Joost Verdaasdonk" <anonymous@discussions.microsoft.com> wrote in message
news:562601c4c9c2$c261bc40$a401280a@phx.gbl...
> 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



Re: Run once macro by Gal

Gal
Mon Nov 15 04:58:55 CST 2004

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

"James" <tvwatchr2@earthlink.net> wrote in message
news:Om%2350iryEHA.2572@tk2msftngp13.phx.gbl...
> Joost Verdaasdonk,
> Thanks for the help, I am going to put this to work first thing Monday
> morning
> James
>
>
> "Joost Verdaasdonk" <anonymous@discussions.microsoft.com> wrote in message
> news:562601c4c9c2$c261bc40$a401280a@phx.gbl...
>> 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
>
>