If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > How to use different Face ID's in a Toolbar.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-09-10, 17:34
abhay_547 abhay_547 is offline
Registered User
 
Join Date: Sep 2009
Posts: 78
How to use different Face ID's in a Toolbar.

Hi All,

I have a code to create a toolbar in Excel. I use the below code to create an addin for my macros. Now I have 3 macros in my toolbar and but I can assign Face ID to only my first macro and other 2 macros get immediate next Face ID's assigned automatically. I want to assign different face ID for each macro. For e.g. If I mention in my code Face ID 1102 then it is assigned to my first macro button in my toolbar and by default my code assigns 1103 to Macro 2 button and 1104 to Macro 3 button. I want to assign different face ID's to all three of my macros in my toolbar. I should be able to mention different face id for each macro in my code. Following is my code. It works fine. I tried lot of this to assign different face id's in my code but nothing worked. Can some one suggest a change to my code which will help me to assign different Face ID's for my each macro in toolbar. Please expedite.

HTML Code:
Option Explicit

Public Const ToolBarName As String = "My Toolbar Bar"
'===========================================
Sub Auto_Open()
    Call CreateMenubar
End Sub

'===========================================
Sub Auto_Close()
    Call RemoveMenubar
End Sub

'===========================================
Sub RemoveMenubar()
    On Error Resume Next
    application.CommandBars(ToolBarName).Delete
    On Error GoTo 0
End Sub

'===========================================
Sub CreateMenubar()

    Dim iCtr As Long

    Dim MacNames As Variant
    Dim CapNamess As Variant
    Dim TipText As Variant

    Call RemoveMenubar

    MacNames = Array("Macro1", _
                     "Macro2", _
                     "Macro3")                                      
                    

    CapNamess = Array("MyMacro1", _
                       "MyMacro2", _
                       "MyMacro3")        
                       
                    
                      

    TipText = Array("Click to run Macro1", _
                    "Click to run Macro2", _
                    "Click to run Macro3", _
                    "Retrieve Data")
                    
                                
                   

    With application.CommandBars.Add
        .Name = ToolBarName
        .Left = 200
        .Top = 200
        .Protection = msoBarNoProtection
        .Visible = True
        .Position = msoBarFloating

        For iCtr = LBound(MacNames) To UBound(MacNames)
            With .Controls.Add(Type:=msoControlButton)
                .OnAction = "'" & ThisWorkbook.Name & "'!" & MacNames(iCtr)
                .Caption = CapNamess(iCtr)
                .Style = msoButtonIconAndCaption
                .FaceId = 1102 + iCtr
                .TooltipText = TipText(iCtr)
            End With
        Next iCtr
    End With
End Sub
Thanks for your help in advance.
Reply With Quote
  #2 (permalink)  
Old 04-09-10, 18:48
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
Hi,

Your code looks fine.

I ran it and -
It added a commandbar.
It added 3 commandbarbuttons to the commandbar.
Each commandbarbutton has a different faceid.
Quote:
Following is my code. It works fine. I tried lot of this to assign different face id's in my code but nothing worked. Can some one suggest a change to my code which will help me to assign different Face ID's for my each macro in toolbar.
I don't quite understand the question/problem. You say the code works fine, so I'm assuming that it does the same for you as it did for me. Do you mean that if you try to change the faceid of one of the commandbarbuttons manually then the others change too?
__________________
Colin

RAD Excel Blog

Other tutorials:
Array Formulas | Deleting Rows with VBA
Reply With Quote
  #3 (permalink)  
Old 04-10-10, 02:17
abhay_547 abhay_547 is offline
Registered User
 
Join Date: Sep 2009
Posts: 78
How to use different Face ID's in a Toolbar.

Hi Colin,

Your understanding is correct. When I try to change the faceid of one of the commandbar buttons manually then the other 2 macro button face id's also change. I want to assign different face id's for all 3 macros for example. I want to assign face id 1102 to my macro1 and faceid 98 to macro2 and faceid 208 to macro3. Please let me know what change should i make to my macro in order to assign different face id to each macro in my commandbar.

Thanks for your help in advance.
Reply With Quote
  #4 (permalink)  
Old 04-10-10, 07:26
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
Hi,

Which version of Excel are you using and (just in case) please can you outline the steps you are taking to change the faceid?
__________________
Colin

RAD Excel Blog

Other tutorials:
Array Formulas | Deleting Rows with VBA

Last edited by Colin Legg; 04-11-10 at 12:49.
Reply With Quote
  #5 (permalink)  
Old 04-12-10, 07:19
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
__________________
Colin

RAD Excel Blog

Other tutorials:
Array Formulas | Deleting Rows with VBA
Reply With Quote
Reply

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

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