ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting Excel toolbar or menu icon in C# WITHOUT using builtin icons (https://www.excelbanter.com/excel-programming/280959-setting-excel-toolbar-menu-icon-c-without-using-builtin-icons.html)

Aaron Queenan

Setting Excel toolbar or menu icon in C# WITHOUT using builtin icons
 
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.



Bernie Deitrick[_2_]

Setting Excel toolbar or menu icon in C# WITHOUT using builtin icons
 
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.





Aaron Queenan

Setting Excel toolbar or menu icon in C# WITHOUT using builtin icons
 
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.







Bernie Deitrick[_2_]

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.










All times are GMT +1. The time now is 10:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com