Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    3 Star Lounger
    Join Date
    Oct 2004
    Location
    USA
    Posts
    223
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Toolbar Icon via VBA (2000 sp3)

    I've been reading past posts and finally understand that I need to rebuild my toolbar in order to make it work in a distributed workbook. It's the whole fixed reference versus relative reference thing. OK, I can do that. My question is, how can I assign an icon to the button in VBA after I create it? I figured out ".Style = msoButtonIcon" to make it look right without text but I can't figure out how to assign an icon. Ideally, I'd like to copy the image of a standard button and paste it onto my new one. I tried recording a macro while I did this manually but nothing was recorded.
    Any help would be most appreciated!
    Thanks!

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Toolbar Icon via VBA (2000 sp3)

    Use the faceID property. <post#=255950>post 255950</post#> has some code which lists all the faces and the IDs.

    Steve

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Toolbar Icon via VBA (2000 sp3)

    Some Followup incase you want a custom face:
    <post#=322,552>post 322,552</post#> has some suggstions and techniques for adding a custom face to the button

    Steve

  4. #4
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Toolbar Icon via VBA (2000 sp3)

    If I understand what your are looking for, Office has a huge selection of built-in Icons that you can choose from, using the .FaceID property. See this page from John Walkenbach which includes sample code for creating toolbars, and code (the second item) you can run that identifies all the possible Icons.
    -John ... I float in liquid gardens
    UTC -7ąDS

  5. #5
    3 Star Lounger
    Join Date
    Oct 2004
    Location
    USA
    Posts
    223
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Toolbar Icon via VBA (2000 sp3)

    This is great stuff! Thanks! How come FaceId doesn't come up in the list when I type "."? It isn't listed in the properties of the controls in help either. Where do you guys find these undocumented features?

  6. #6
    3 Star Lounger
    Join Date
    Oct 2004
    Location
    USA
    Posts
    223
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Toolbar Icon via VBA (2000 sp3)

    I have that book! I should have searched there too. Thanks!

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Toolbar Icon via VBA (2000 sp3)

    If you have a reference to the Microsoft Office 9.0 Object Library in Tools | References, you should be able to get help on FaceID by typing it in the Immediate window and pressing F1, or by looking it up in the Object Browser (F2).

    If you declare a variable of type CommandBarButton, IntelliSense will list FaceID among its properties. It's not listed for a variable of type CommandBarControl because it doesn't apply to all kinds of CommandBarControls.

  8. #8
    3 Star Lounger
    Join Date
    Oct 2004
    Location
    USA
    Posts
    223
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Toolbar Icon via VBA (2000 sp3)

    Thanks Hans! You make sense out of chaos, I really appreciate it!

  9. #9
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Toolbar Icon via VBA (2000 sp3)

    How would one go about identifying the "description or text" associated with the faceids?

    As an example from the dropdown of "File" you can select "File Search" which has a faceid associated with it. I would like to easily identify the faceid number to the description or text.

    John

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Toolbar Icon via VBA (2000 sp3)

    See the posts referred to higher up in this thread. You can create a list of all built-in commandbar controls with their caption and faceid.

  11. #11
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Toolbar Icon via VBA (2000 sp3)

    Hans,

    I must be missing something. I ran the code and it does return a faceid as well as the number of the id. What about the caption? This is the text I am looking for.

    Regards,
    John

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Toolbar Icon via VBA (2000 sp3)

    It's very easy to add the Caption to the output of the code.

  13. #13
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Toolbar Icon via VBA (2000 sp3)

    Hans,

    Easier said than done. I have been working on it for some time now and still have not come up with a reasonable solution.

    I should be able to display the caption but can not capture it.

    Regards,
    John

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Toolbar Icon via VBA (2000 sp3)

    Caption is not a property of FaceID, but of a commandbar control, so use

    MsgBox cbCtl.Caption

  15. #15
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Toolbar Icon via VBA (2000 sp3)

    Hans,

    I have already tried your suggestion previously to my post. All I get returned is a "blank".

    Regards,
    John

Page 1 of 2 12 LastLast

Posting Permissions

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