AW: Symbol in CommandButton einfügen
14.01.2021 19:32:38
Nepumuk
Hallo Micha,
ein Beispiel:
Private Sub UserForm_Activate()
CommandButton1.Picture = CommandBars(9).Controls(7).Picture
End Sub
An die Icons kommst du so:
Option Explicit
Private Declare PtrSafe Function MakeSureDirectoryPathExists Lib "imagehlp.dll" ( _
ByVal DirPath As String) As Long
Public Sub Export_Icons()
Dim objPicture As IPictureDisp
Dim objCommandBar As CommandBar
Dim objCommandBarControl As CommandBarControl
Dim strPath As String
strPath = ThisWorkbook.Path & "\CommandbarIcons\"
Call MakeSureDirectoryPathExists(strPath)
On Error Resume Next
For Each objCommandBar In CommandBars
For Each objCommandBarControl In objCommandBar.Controls
Set objPicture = objCommandBarControl.Picture
If Err.Number = 0 Then
Call stdole.SavePicture(Picture:=objPicture, _
Filename:=strPath & Format$(objCommandBar.Index, "000") & _
"_" & Format$(objCommandBarControl.Index, "000") & ".bmp")
Else
Err.Clear
End If
Next
Next
End Sub
Die 1. Zahl ist die Commandbar die 2. Zahl das Control. Es gibt viel mehr Icons, wenn du das gewünscht nicht findest, dann melde dich.
Wenn du die RibbonIcons in einem Commanbutton nutzen willst, dann so:
Private Sub UserForm_Initialize()
Set CommandButton1.Picture = _
Application.CommandBars.GetImageMso("AnimationTriggerAddMenu", 20, 20)
Set CommandButton2.Picture = _
Application.CommandBars.GetImageMso("PrintPreviewClose", 20, 20)
End Sub
Die Bezeichnung des Icons findest du in der IconGallery dieser Mappe:
https://www.herber.de/bbs/user/143016.zip
Gruß
Nepumuk