LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.interopoledde,microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default Setting Excel toolbar or menu icon in C# WITHOUT using builtin icons

Aaron,

The first sub below will make 4 big toolbars that show the ID numbers
when you hover your pointer over them. The second removes them. There
are other utilities out there but I never recorded where they are, or
saved those messages.

HTH,
Bernie
MS Excel MVP

Sub ShowFaceIDs()
Dim NewToolbar As CommandBar
Dim NewButton As CommandBarButton
Dim i As Integer, IDStart As Integer, IDStop As Integer

' Delete existing FaceIds toolbar if it exists
CleanUp

' Add an empty toolbar
Set NewToolbar = Application.CommandBars.Add _
(Name:="FaceIds1", temporary:=True)
NewToolbar.Visible = True

' Change the following values to see different FaceIDs
IDStart = 1
IDStop = 250

For i = IDStart To IDStop
Set NewButton = NewToolbar.Controls.Add _
(Type:=msoControlButton, ID:=2950)
NewButton.FaceId = i
NewButton.Caption = "FaceID = " & i
Next i
NewToolbar.Width = 600

' Add an empty toolbar
Set NewToolbar = Application.CommandBars.Add _
(Name:="FaceIds2", temporary:=True)
NewToolbar.Visible = True

' Change the following values to see different FaceIDs
IDStart = 251
IDStop = 500

For i = IDStart To IDStop
Set NewButton = NewToolbar.Controls.Add _
(Type:=msoControlButton, ID:=2950)
NewButton.FaceId = i
NewButton.Caption = "FaceID = " & i
Next i
NewToolbar.Width = 600

' Add an empty toolbar
Set NewToolbar = Application.CommandBars.Add _
(Name:="FaceIds3", temporary:=True)
NewToolbar.Visible = True

' Change the following values to see different FaceIDs
IDStart = 501
IDStop = 750

For i = IDStart To IDStop
Set NewButton = NewToolbar.Controls.Add _
(Type:=msoControlButton, ID:=2950)
NewButton.FaceId = i
NewButton.Caption = "FaceID = " & i
Next i
NewToolbar.Width = 600

' Add an empty toolbar
Set NewToolbar = Application.CommandBars.Add _
(Name:="FaceIds4", temporary:=True)
NewToolbar.Visible = True

' Change the following values to see different FaceIDs
IDStart = 751
IDStop = 1000

For i = IDStart To IDStop
Set NewButton = NewToolbar.Controls.Add _
(Type:=msoControlButton, ID:=2950)
NewButton.FaceId = i
NewButton.Caption = "FaceID = " & i
Next i
NewToolbar.Width = 600
End Sub

Sub CleanUp()
On Error Resume Next
Application.CommandBars("FaceIds").Delete
Application.CommandBars("FaceIds1").Delete
Application.CommandBars("FaceIds2").Delete
Application.CommandBars("FaceIds3").Delete
Application.CommandBars("FaceIds4").Delete

End Sub

"Aaron Queenan" wrote in
message ...
Thanks, Bernie. I'd suspected as much.

The problem with using the clipboard is that it is common for a user

to copy
text to the clipboard, start Excel, then paste it. If I use the

clipboard
to create the toolbar icon, the user's text will be removed from the
clipboard. I don't want to create a permanent toolbar, because then

if the
user logs into a computer without the add-in installed using a

roaming
profile, the toolbar will display but won't work.

Do you know if there is a file where the built-in button faces are

stored?
I've searched the hard disk for the icons, but can't find anything

that
looks like the built-in button faces. I'm thinking that perhaps I

can add
the icon to that file and then use the next sequence number for the

..IdFace.

Thanks,
Aaron.

"Bernie Deitrick" wrote in message
...
Aaron,

You can't.

You have to use the clipboard to some extent to set the control's
face, either by copying a picture and pasting it, or by copying
another face using .CopyFace and .PasteFace.

HTH,
Bernie
MS Excel MVP

"Aaron Queenan" wrote

in
message ...
How can I set the icon of a toolbar option or menu icon without

using the
builtin icons and without using the clipboard?

Thanks,
Aaron Queenan.








 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
What causes custom icons in the excel standard toolbar Donald1929 Excel Discussion (Misc queries) 2 December 1st 07 07:11 AM
Excel 2007 Toolbar Icons JonathanS Setting up and Configuration of Excel 2 June 11th 07 08:55 AM
Excel 2003 Toolbar Icons are fuzzy and out of focus Jimmer Excel Discussion (Misc queries) 3 February 14th 06 01:42 PM
Excel formatting toolbar icons Hunter Excel Discussion (Misc queries) 2 February 7th 05 07:38 PM
Fax Icon on my File menu and toolbar Timsr Excel Discussion (Misc queries) 1 December 10th 04 12:09 AM


All times are GMT +1. The time now is 02:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"