Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Stop macro from running more than once?

0 views
Skip to first unread message

Nikki

unread,
Apr 18, 2005, 10:08:01 AM4/18/05
to
Ive added a Combobox to my presentation (set up with a macro) to run when an
action buttion is clicked. If you click the action buttion more than once,
the content repeats itself.

How do you stop the content from repeating in the combobox even if you click
the action buttion more than once? Please see the folowing code...

Thanks!

Sub ComboBox1_Change()

ComboBox1.AddItem ("Proprietary Information")
ComboBox1.AddItem ("Employee Information")
ComboBox1.AddItem ("Customer Information")
ComboBox1.AddItem ("Personal Information")
ComboBox1.AddItem ("Other Information")

End Sub

Bill Foley

unread,
Apr 18, 2005, 10:19:55 AM4/18/05
to
A couple of ways come to mind:

1. You could name the action button the macro is tied to (ButtonClicked) and
have a line of code that hides the button after clicked. That way you can't
click it again. You would obviously need some sort of "initialization" code
that set it back to True so when you get to the slide it is visible. If the
button is on Slide 1, the code to hide it would be (after it is named of
course):

ActivePresentation.Slides(1).Shapes("ButtonClicked").Visible = False

2. You could have a variable "ButtonClicked" that is set to False upon some
sort of initialization. When the button is clicked, it runs an IF...Then
clause. If it is "False" it loads the ComboBox with your stuff, THEN sets
"ButtonClicked" to True. If you click the button again, it will skip the
ComboBox AddItem part of the code and just exit the Sub.

--
Bill Foley, Microsoft MVP (PowerPoint)
Microsoft Office Specialist Master Instructor - XP
www.pttinc.com
Check out PPT FAQs at: http://www.rdpslides.com/pptfaq/
Check out Word FAQs at: http://word.mvps.org/FAQs/General/index.htm

"Nikki" <Ni...@discussions.microsoft.com> wrote in message
news:A1702DC8-B750-49C7...@microsoft.com...

Bill Dilworth

unread,
Apr 18, 2005, 10:39:07 AM4/18/05
to
Another method:

Private Sub ComboBox1_GotFocus()
If ComboBox1.ListCount < 2 Then


ComboBox1.AddItem ("Proprietary Information")
ComboBox1.AddItem ("Employee Information")
ComboBox1.AddItem ("Customer Information")
ComboBox1.AddItem ("Personal Information")
ComboBox1.AddItem ("Other Information")

End If
End Sub


--

Bill Dilworth
Microsoft PPT MVP Team
Users helping fellow users.
===============
Please spend a few minutes checking vestprog2@
out www.pptfaq.com This link will yahoo.
answer most of your questions, before com
you think to ask them.

Change org to com to defuse anti-spam,
ant-virus, anti-nuisance misdirection.
.
.

"Nikki" <Ni...@discussions.microsoft.com> wrote in message
news:A1702DC8-B750-49C7...@microsoft.com...

Bill Foley

unread,
Apr 18, 2005, 10:45:20 AM4/18/05
to
Duh! Much easier than mine. And to think I almost got that round peg in
that square hole!

--
Bill Foley, Microsoft MVP (PowerPoint)
Microsoft Office Specialist Master Instructor - XP
www.pttinc.com
Check out PPT FAQs at: http://www.rdpslides.com/pptfaq/
Check out Word FAQs at: http://word.mvps.org/FAQs/General/index.htm

"Bill Dilworth" <vest...@yahoo.org> wrote in message
news:%23Tw9hRC...@TK2MSFTNGP10.phx.gbl...

Chirag

unread,
Apr 18, 2005, 10:48:17 AM4/18/05
to
Change the macro to:

Sub ComboBox1_Change()
ComboBox1.Clear


ComboBox1.AddItem ("Proprietary Information")
ComboBox1.AddItem ("Employee Information")
ComboBox1.AddItem ("Customer Information")
ComboBox1.AddItem ("Personal Information")
ComboBox1.AddItem ("Other Information")
End Sub

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html

"Nikki" <Ni...@discussions.microsoft.com> wrote in message
news:A1702DC8-B750-49C7...@microsoft.com...

Nikki

unread,
Apr 18, 2005, 10:59:04 AM4/18/05
to
Thank you...

Does it have to be "Private Sub" as opposed to "Sub"? How are the two
different?


Then
> ComboBox1.AddItem ("Proprietary Information")
> ComboBox1.AddItem ("Employee Information")
> ComboBox1.AddItem ("Customer Information")
> ComboBox1.AddItem ("Personal Information")
> ComboBox1.AddItem ("Other Information")
> End If
> End Sub
>
>
> --
>
> Bill Dilworth
> Microsoft PPT MVP Team
> Users helping fellow users.
> ===============
> Please spend a few minutes checking vestprog2@
> out www.pptfaq.com This link will yahoo.
> answer most of your questions, before com
> you think to ask them.
>
> Change org to com to defuse anti-spam,
> ant-virus, anti-nuisance misdirection.
> ..

> ..

Bill Foley

unread,
Apr 18, 2005, 11:03:22 AM4/18/05
to
Shweet!

--
Bill Foley, Microsoft MVP (PowerPoint)
Microsoft Office Specialist Master Instructor - XP
www.pttinc.com
Check out PPT FAQs at: http://www.rdpslides.com/pptfaq/
Check out Word FAQs at: http://word.mvps.org/FAQs/General/index.htm

"Chirag" <my_email_is@my_website.com> wrote in message
news:OVNAqWCR...@TK2MSFTNGP15.phx.gbl...

Nikki

unread,
Apr 18, 2005, 11:24:03 AM4/18/05
to
Thank you....This worked great!

Bill Dilworth

unread,
Apr 18, 2005, 11:55:15 AM4/18/05
to
The problem with this method, Chirag, is that it clears the selection made
by the act of selecting it. I know this because I beat my head against a
wall trying to figure out why I could not select an item from a list I
updated this way.

However, you can still combine the two methods and use:

Sub ComboBox1_Change()

If ComboBox1.listCount <2 then


ComboBox1.Clear
ComboBox1.AddItem ("Proprietary Information")
ComboBox1.AddItem ("Employee Information")
ComboBox1.AddItem ("Customer Information")
ComboBox1.AddItem ("Personal Information")
ComboBox1.AddItem ("Other Information")

End If

End Sub


Nikki

unread,
Apr 18, 2005, 12:19:02 PM4/18/05
to
I see what you mean! Your way works!

Thanks again!

Chirag

unread,
Apr 19, 2005, 7:39:06 AM4/19/05
to
Yes, that is correct.

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html

"Bill Dilworth" <vest...@yahoo.org> wrote in message
news:eTvaE8CR...@TK2MSFTNGP14.phx.gbl...

0 new messages