PC Review


Reply
Thread Tools Rate Thread

Deleting CommandBar("").Controls

 
 
itsthedude@gmail.com
Guest
Posts: n/a
 
      8th Jan 2008
Is it possible to use a WorksheetFunction when looking at CommandBar
data? What i'm trying to do is search the names of the CommandBars
and delete any that contains a certain string. I've got the function
written to remove the ampersand and could write one to find the
string, but is there a way to use the .Find function to do this?

I've tried a couple different ways and can't think of how to get it to
work... any ideas?


Sub AddMenuItems()

For Each ctl In Application.CommandBars("Worksheet Menu
Bar").Controls
header_name = ctl.Caption
head_count = Len(header_name)
For i = 1 To Len(header_name)
If Right(Left(header_name, i), 1) = "&" Then
header_name = Left(header_name, i - 1) & _
Right(header_name, head_count - i)
End If
Next

'With header_name
' c = header_name.Find( _
' what:=find_item, _
' MatchCase:=False)
'End With
find_item = "String to look for"
a = WorksheetFunction.Find(find_item, header_name, 1)

found_MP = header_name.indexof(find_item)

Next

End Sub

Sub Auto_Open()
AddMenuItems
End Sub


Thanks,
Thedude
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      8th Jan 2008
VBA has its own equivalent. Look at VBA's help for instr().

(E-Mail Removed) wrote:
>
> Is it possible to use a WorksheetFunction when looking at CommandBar
> data? What i'm trying to do is search the names of the CommandBars
> and delete any that contains a certain string. I've got the function
> written to remove the ampersand and could write one to find the
> string, but is there a way to use the .Find function to do this?
>
> I've tried a couple different ways and can't think of how to get it to
> work... any ideas?
>
> Sub AddMenuItems()
>
> For Each ctl In Application.CommandBars("Worksheet Menu
> Bar").Controls
> header_name = ctl.Caption
> head_count = Len(header_name)
> For i = 1 To Len(header_name)
> If Right(Left(header_name, i), 1) = "&" Then
> header_name = Left(header_name, i - 1) & _
> Right(header_name, head_count - i)
> End If
> Next
>
> 'With header_name
> ' c = header_name.Find( _
> ' what:=find_item, _
> ' MatchCase:=False)
> 'End With
> find_item = "String to look for"
> a = WorksheetFunction.Find(find_item, header_name, 1)
>
> found_MP = header_name.indexof(find_item)
>
> Next
>
> End Sub
>
> Sub Auto_Open()
> AddMenuItems
> End Sub
>
> Thanks,
> Thedude


--

Dave Peterson
 
Reply With Quote
 
itsthedude@gmail.com
Guest
Posts: n/a
 
      9th Jan 2008
Dave,

Do you ever get a solution in your head... then blindly work towards
that solution instead of working towards a much more logical goal?
Thank goodness there are guys like you around here to point people
like me in the right direction.

Thanks,
Thedude

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      9th Jan 2008
Lots of times.

It's always nice to get another pair (or lots of pairs) of eyes to help.

(E-Mail Removed) wrote:
>
> Dave,
>
> Do you ever get a solution in your head... then blindly work towards
> that solution instead of working towards a much more logical goal?
> Thank goodness there are guys like you around here to point people
> like me in the right direction.
>
> Thanks,
> Thedude


--

Dave Peterson
 
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
CommandBar and Controls (how to create separate "Sets" of Controls) EagleOne@discussions.microsoft.com Microsoft Excel Programming 4 26th Mar 2010 04:33 PM
Seens there are "standard Microsoft Windows controls" and "common controls" Academia Microsoft VC .NET 4 18th Jan 2008 01:13 AM
Outlook 2003: Want to access commandbar in "New message" window Steffen Grellmann Microsoft Outlook Program Addins 0 30th Jun 2007 12:39 PM
"Start a new group" coding possible for a commandbar (floating toolbar)? StargateFanFromWork Microsoft Excel Programming 1 19th Jun 2006 03:56 PM
Deleting ActiveX Controls-Do these "Regenerate"? Eli Windows XP Internet Explorer 1 31st May 2004 11:05 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:06 PM.