Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2008

Tip: Looking for answers? Try searching our database.

Adding an input box to a custom toolbar

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Charles - 27 Mar 2008 23:27 GMT
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
FSt1 - 28 Mar 2008 00:53 GMT
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

> Hello
>
[quoted text clipped - 8 lines]
> Thanks
> Charles
cht13er - 28 Mar 2008 01:10 GMT
> hi
> i know of nothing built into excel that would do that.
[quoted text clipped - 25 lines]
> > 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
Charles - 28 Mar 2008 08:36 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.