Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    Leigh on Sea, Essex, England
    Posts
    263
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Custom faces on buttons

    Hi. Me again.

    While sorting out the last problem (see thread below) I followed another thread which told me how to create and destory toolbars in code, putting it into an XLA add-in.

    I tried this, and it's great - but one question:

    How can you put a custom face onto a button in code?

    Thanks.

    Stuart

  2. #2
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Kortrijk, Belgium
    Posts
    571
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Custom faces on buttons

    There are over 5500 faces, so why do you want to make your own custom face. This is just to say that I don't know how to do it. But, here is some code, that displays the built in button faces:

    <pre>Sub FaceIDs()
    Dim i As Integer
    Dim j As Integer
    Dim k As Integer
    Dim CbCtl As CommandBarControl
    Dim CBBar As CommandBar
    On Error Resume Next
    Application.ScreenUpdating = False
    Set CBBar = CommandBars.Add(Position:=msoBarFloating, MenuBar:=False, temporary:=True)
    Set CbCtl = CBBar.Controls.Add(Type:=msoControlButton, temporary:=True)
    k = 1
    Do While Err.Number = 0
    For j = 1 To 10
    i = i + 1
    Application.StatusBar = "FaceID = " & i
    CbCtl.FaceId = i
    CbCtl.CopyFace
    If Err.Number <> 0 Then Exit For
    ActiveSheet.Paste Cells(k, j + 1)
    Cells(k, j).Value = i
    Next j
    k = k + 1
    Loop
    Application.StatusBar = False
    CBBar.Delete
    End Sub
    </pre>


  3. #3
    5 Star Lounger
    Join Date
    Dec 2002
    Location
    Perth, Western Australia, Australia
    Posts
    730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Custom faces on buttons

    Better late, than never?

    How To Create a Transparent Picture For Office CommandBar Buttons
    &
    How To Set the Mask and Picture Properties for Office XP CommandBars

    I want to do the same thing, and after some arduous Googling unearthed the above. They look promising, but may not be for the fainthearted (the first has about 300 lines of VBA code using APIs). For an XP environment, the second is much less involved.

    I don't have time to implement immediately (mixed environment, so I'm stuck with the first approach), but will report progress if/when any is made.
    <font face="Comic Sans MS" color="blue">TimOz</font>
    <img src=/S/flags/Finland.gif border=0 alt=Finland width=30 height=18> <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •