Welcome to the { mindfrost82.com } forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Excel

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-21-2008, 02:59 AM
Craig Brandt
 
Posts: n/a
Excel 2003 - VBA - Buttons

I need someone to give me a few buzz words and point me to some reference
work so that I can get started.

I want to place several buttons on a worksheet that will help the user move
around. I need to create a button then upon activation change the Caption
and execute a macro that will create a button on another sheet. upon
activation of this button, I will execute a macro and at the end of the
macro, delete the button.
In order to work with the button I need to name it then address it to make
the changes and ultimately delete it.

Here is the code I used to create the first button:
ActiveSheet.Buttons.Add(1245, 16, 64, 16).Select
Selection.Caption = "AutoFocus On"
Selection.Name = "AutoFocusBut"
Selection.OnAction = "FocusOn"
In the routine "FocusOn" I want to look at the caption to determine the
needed activity, then change the caption. Up to now the button has been
selected. It will not be when I come back. How do I select the button, and
test the caption.
I thought I knew, but obviously I am missing something.
References anyone?

Craig



Reply With Quote
  #2 (permalink)  
Old 05-21-2008, 09:17 AM
Bob Phillips
 
Posts: n/a
Re: Excel 2003 - VBA - Buttons

Sub CreateButton1()
Dim btn1 As Object
Set btn1 = ActiveSheet.Buttons.Add(1245, 16, 64, 16)
With btn1

.Caption = "AutoFocus On"
.Name = "AutoFocusBut"
.OnAction = "FocusOn"
End With

End Sub

Sub FocusOn()
Dim btn2 As Object

Set btn2 = ActiveSheet.Buttons.Add(1000, 16, 64, 16)
With btn2

.Caption = "Button2"
.Name = "Button2"
.OnAction = "RunButton2"
End With

ActiveSheet.Buttons("AutoFocusBut").Caption = "Changed"

End Sub

Sub RunButton2()
ActiveSheet.Buttons("AutoFocusBut").Delete
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Craig Brandt" <brandtcraig@att.net> wrote in message
news:gmLYj.4183$ah4.2147@flpi148.ffdc.sbc.com...
>I need someone to give me a few buzz words and point me to some reference
> work so that I can get started.
>
> I want to place several buttons on a worksheet that will help the user
> move
> around. I need to create a button then upon activation change the Caption
> and execute a macro that will create a button on another sheet. upon
> activation of this button, I will execute a macro and at the end of the
> macro, delete the button.
> In order to work with the button I need to name it then address it to make
> the changes and ultimately delete it.
>
> Here is the code I used to create the first button:
> ActiveSheet.Buttons.Add(1245, 16, 64, 16).Select
> Selection.Caption = "AutoFocus On"
> Selection.Name = "AutoFocusBut"
> Selection.OnAction = "FocusOn"
> In the routine "FocusOn" I want to look at the caption to determine the
> needed activity, then change the caption. Up to now the button has been
> selected. It will not be when I come back. How do I select the button, and
> test the caption.
> I thought I knew, but obviously I am missing something.
> References anyone?
>
> Craig
>
>
>



Reply With Quote
  #3 (permalink)  
Old 05-21-2008, 03:02 PM
Craig Brandt
 
Posts: n/a
Re: Excel 2003 - VBA - Buttons - Thanks

Bob:
After reviewing your code, I think part of my problem was that I was on a
different sheet when I tried to address the button plus I didn't use the
"Set" code.
Thanks much for the input.
Craig

"Bob Phillips" <bob.NGs@somewhere.com> wrote in message
news:enwmwsxuIHA.2208@TK2MSFTNGP04.phx.gbl...
> Sub CreateButton1()
> Dim btn1 As Object
> Set btn1 = ActiveSheet.Buttons.Add(1245, 16, 64, 16)
> With btn1
>
> .Caption = "AutoFocus On"
> .Name = "AutoFocusBut"
> .OnAction = "FocusOn"
> End With
>
> End Sub
>
> Sub FocusOn()
> Dim btn2 As Object
>
> Set btn2 = ActiveSheet.Buttons.Add(1000, 16, 64, 16)
> With btn2
>
> .Caption = "Button2"
> .Name = "Button2"
> .OnAction = "RunButton2"
> End With
>
> ActiveSheet.Buttons("AutoFocusBut").Caption = "Changed"
>
> End Sub
>
> Sub RunButton2()
> ActiveSheet.Buttons("AutoFocusBut").Delete
> End Sub
>
>
> --
> ---
> HTH
>
> Bob
>
>
> (there's no email, no snail mail, but somewhere should be gmail in my

addy)
>
>
>
> "Craig Brandt" <brandtcraig@att.net> wrote in message
> news:gmLYj.4183$ah4.2147@flpi148.ffdc.sbc.com...
> >I need someone to give me a few buzz words and point me to some reference
> > work so that I can get started.
> >
> > I want to place several buttons on a worksheet that will help the user
> > move
> > around. I need to create a button then upon activation change the

Caption
> > and execute a macro that will create a button on another sheet. upon
> > activation of this button, I will execute a macro and at the end of the
> > macro, delete the button.
> > In order to work with the button I need to name it then address it to

make
> > the changes and ultimately delete it.
> >
> > Here is the code I used to create the first button:
> > ActiveSheet.Buttons.Add(1245, 16, 64, 16).Select
> > Selection.Caption = "AutoFocus On"
> > Selection.Name = "AutoFocusBut"
> > Selection.OnAction = "FocusOn"
> > In the routine "FocusOn" I want to look at the caption to determine the
> > needed activity, then change the caption. Up to now the button has been
> > selected. It will not be when I come back. How do I select the button,

and
> > test the caption.
> > I thought I knew, but obviously I am missing something.
> > References anyone?
> >
> > Craig
> >
> >
> >

>
>



Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Excel


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:14 AM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Chomsky | Bad Credit Mortgages | Online Loans | Business Credit Cards | Facebook Proxy



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114