PC Review


Reply
Thread Tools Rate Thread

Adding an input box to a custom toolbar

 
 
Charles
Guest
Posts: n/a
 
      27th Mar 2008
Hello

is there a way to add not a button but an input box into a custom
toolbar in excel. I would like the user to type some text in the
toolbar, press enter and a macro would launch at grab the text. I
think it is feasible, but I can't see any article/post/webpage on the
topic.

Would anyone have any idea?

Thanks
Charles
 
Reply With Quote
 
 
 
 
FSt1
Guest
Posts: n/a
 
      27th Mar 2008
hi
i know of nothing built into excel that would do that.
what i would do is put a custom icon on the toolbar to lauch the macro and
start the macro with an input box.
sub example()
dim txt as string
txt = inputbox ("enter something")
'txt would be the variable input into the inputbox.
your code here
end sub.
it would do essentially what you want except the input box wouldn't be on
the toolbar, just the custom icon that lauches the macro.

my thoughts
Regards
FSt1
"Charles" wrote:

> Hello
>
> is there a way to add not a button but an input box into a custom
> toolbar in excel. I would like the user to type some text in the
> toolbar, press enter and a macro would launch at grab the text. I
> think it is feasible, but I can't see any article/post/webpage on the
> topic.
>
> Would anyone have any idea?
>
> Thanks
> Charles
>

 
Reply With Quote
 
cht13er
Guest
Posts: n/a
 
      28th Mar 2008
On Mar 27, 7:53 pm, FSt1 <F...@discussions.microsoft.com> wrote:
> hi
> i know of nothing built into excel that would do that.
> what i would do is put a custom icon on the toolbar to lauch the macro and
> start the macro with an input box.
> sub example()
> dim txt as string
> txt = inputbox ("enter something")
> 'txt would be the variable input into the inputbox.
> your code here
> end sub.
> it would do essentially what you want except the input box wouldn't be on
> the toolbar, just the custom icon that lauches the macro.
>
> my thoughts
> Regards
> FSt1
>
> "Charles" wrote:
> > Hello

>
> > is there a way to add not a button but an input box into a custom
> > toolbar in excel. I would like the user to type some text in the
> > toolbar, press enter and a macro would launch at grab the text. I
> > think it is feasible, but I can't see any article/post/webpage on the
> > topic.

>
> > Would anyone have any idea?

>
> > Thanks
> > Charles


I've never heard of it / seen it either ... if you find anything be
sure to post it here!

(The advice from FSt1 sounds good)

Chris
 
Reply With Quote
 
Charles
Guest
Posts: n/a
 
      28th Mar 2008
I've actually been lucky:

http://www.ozgrid.com/forum/showthread.php?t=23224

it looks like this would work. tricky....

Public Const g_strCBRName As String = "MyCustomBar"

Sub CustomTB()

Dim cbrTemp As CommandBar
Dim objDrop As CommandBarControl

RemoveCustomTB

'Create commandbar
Set cbrTemp = Application.CommandBars.Add(g_strCBRName)

With cbrTemp
' Add control
Set objDrop = .Controls.Add(msoControlComboBox)
With objDrop
' add items
.AddItem "Andy"
.AddItem "Bob"
.AddItem "Charlie"
.OnAction = "cbrTest"
End With
' Add control textbox
Set objDrop = .Controls.Add(msoControlEdit)
With objDrop
.OnAction = "ctxTest"
End With
.Visible = True
End With

End Sub
Sub cbrTest()
MsgBox "You selected " &
Application.CommandBars(g_strCBRName).Controls(1).Text
End Sub
Sub ctxTest()
MsgBox "You entered " &
Application.CommandBars(g_strCBRName).Controls(2).Text
End Sub

Sub RemoveCustomTB()
' Try and delete commandbar
On Error Resume Next
Application.CommandBars(g_strCBRName).Delete
End Sub

Thanks
Charles
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding custom buttons to the Standard toolbar versus a custom toolbar cainrandom@gmail.com Microsoft Outlook Program Addins 2 9th Oct 2008 05:13 PM
adding custom images to a button on custom toolbar Mousam Microsoft Excel Programming 1 13th Jul 2007 04:28 PM
Adding Custom Toolbar =?Utf-8?B?VG9kZA==?= Microsoft Word Document Management 11 18th Oct 2006 11:49 PM
Inspector and adding a custom toolbar =?Utf-8?B?UGF1bCBIZWluaXNjaA==?= Microsoft Outlook Program Addins 7 5th Sep 2006 06:00 PM
Adding custom button to toolbar =?Utf-8?B?S2F0aHk=?= Microsoft Outlook Discussion 1 16th Jul 2006 09:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:32 AM.