Consulting

Results 1 to 7 of 7

Thread: Face IDs and Buttons

  1. #1
    VBAX Regular
    Joined
    Aug 2010
    Posts
    19
    Location

    Face IDs and Buttons

    I found this code online for faceids;

    [vba]Sub MakeAllFaceIDs()
    'make 14 toolbars, with 300 faces each
    'note that maxid is greater than last valid ID, so error will
    'occur when first invalid ID is used
    Const maxId = 3900
    On Error GoTo realMax
    For bars = 0 To 13
    firstId = bars * 300
    lastId = firstId + 299
    Set tb = CommandBars.Add
    For I = firstId To lastId
    Set btn = tb.Controls.Add
    btn.FaceId = I
    btn.TooltipText = "Faceid = " & I
    Next
    tb.Name = ("Faces " & CStr(firstId) & " to " & CStr(lastId))
    tb.Width = 591
    tb.Visible = True
    Next
    'Delete the button that caused the error and set toolbar name
    realMax:
    btn.Delete
    tb.Name = ("Faces " & CStr(firstId) & " to " & CStr(I - 1))
    tb.Width = 591
    tb.Visible = True
    End Sub [/vba]

    I would ideally like to be able to use one of the images used in the face IDs (in particular number 1550) as the image on a command button but can't seem to find a way of calling the image in a way that allows it to be used like this. Is there anyway of doing this?

    Thanks.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You just set the FaceId property of your button to that number.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Aug 2010
    Posts
    19
    Location
    I didn't think there was (can't find) a faceID property for a command button. Would you be able to provide a line with this?

    Thanks

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I am referring to buttons that you add to a menu or toolbar in Excel. Are we talking about the same thing?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Regular
    Joined
    Aug 2010
    Posts
    19
    Location
    No, i am trying to use it on a standard command button that can be used on a userform. Sorry, maybe i should've been more clear.

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Then you need to create an image file (gif, jpg) and use the Picture property of the button.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    MS Excel MVP VBAX Mentor Andy Pope's Avatar
    Joined
    May 2004
    Location
    Essex, England
    Posts
    344
    Location
    You can make use of Stephen Bullen's PastePicture code to copy and paste FaceID images.
    You also need to create a temporary commandbar and button in order to make use of CopyFace method.
    Cheers
    Andy

Posting Permissions

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