Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1044to1048
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Feste Office-Befehle in eigene Symbolleiste

Feste Office-Befehle in eigene Symbolleiste
02.02.2009 14:10:02
Florian
Hallo!
Ich hab mir ein Add-In erstellt, das eine eigene Symbolleiste mit eigenen Symbolen erstellt.
Das funktioniert einwandfrei! Hier ist das Add-In: https://www.herber.de/bbs/user/58997.xla
Das ist der Code daraus:

Private Sub Workbook_Open()
Dim CB As CommandBar
Dim CBC As CommandBarButton
Dim I As Integer
On Error Resume Next
Set CB = Application.CommandBars.Add(Name:="Meine Symbolleiste", temporary:=True, Position:= _
_
_
msoBarTop)
On Error GoTo 0
If Application.CommandBars("Meine Symbolleiste").Visible = False Then
CB.Visible = True
'       Code von jinx zur Position
'       RowIndex 3 --> vor Standard-Symbolleiste
'       Rowindex 4 --> vor Formatsymbolleiste
CB.RowIndex = Application.CommandBars("Standard").RowIndex
'       Left = 0 ---> wird vor existierende Symbolleiste eingefügt
'       Left > 0 --> Wird hinter Symbolleiste angefügt
CB.Left = 0
Application.CommandBars("Formatting").Left = 0
Application.CommandBars("Standard").Left = 0
For I = 1 To 8
Set CBC = CB.Controls.Add(Type:=msoControlButton)
With CBC
'                .Width = 35                 ' Breite der Schalter
'                .Style = msoButtonCaption   ' Text auf Schaltfläche
Select Case I
Case 1
ThisWorkbook.Worksheets("Icons").Shapes("Bild 1").Copy
.Caption = "Format: Auswertung"
.OnAction = "Format_Auswertung"
.Style = msoButtonIcon
.PasteFace
Case 2
ThisWorkbook.Worksheets("Icons").Shapes("Bild 2").Copy
.Caption = "Fußzeile"
.OnAction = "Fußzeile_einfügen"
.Style = msoButtonIcon
.PasteFace
Case 3
ThisWorkbook.Worksheets("Icons").Shapes("Bild 3").Copy
.Caption = "CSV Speichern"
.OnAction = "CSV_als_XLS_Speichern"
.Style = msoButtonIcon
.PasteFace
.BeginGroup = True
Case 4
ThisWorkbook.Worksheets("Icons").Shapes("Bild 4").Copy
.Caption = "Querformat"
.OnAction = "Querformat"
.Style = msoButtonIcon
.PasteFace
.BeginGroup = True
Case 5
ThisWorkbook.Worksheets("Icons").Shapes("Bild 5").Copy
.Caption = "Seitenrand vergrößern"
.OnAction = "Seitenrand_vergroessern"
.Style = msoButtonIcon
.PasteFace
Case 6
ThisWorkbook.Worksheets("Icons").Shapes("Bild 6").Copy
.Caption = "Automatischer Seitenumbruch"
.OnAction = "Automatischer_Seitenumbruch"
.Style = msoButtonIcon
.PasteFace
.BeginGroup = True
Case 7
ThisWorkbook.Worksheets("Icons").Shapes("Bild 7").Copy
.Caption = "Als Datum"
.OnAction = "Als_DATUM_formatieren"
.Style = msoButtonIcon
.PasteFace
.BeginGroup = True
Case 8
ThisWorkbook.Worksheets("Icons").Shapes("Bild 8").Copy
.Caption = "Als TEXT/ZAHL formatieren"
.OnAction = "Als_TEXT_formatieren"
.Style = msoButtonIcon
.PasteFace
End Select
End With
Next I
End If
End Sub



Private Sub Workbook_Deactivate()
'   Symbolleiste ausblenden bei Dateiwechsel
On Error Resume Next
If Application.CommandBars("Meine Symbolleiste").Visible = True Then Application. _
CommandBars("Meine Symbolleiste").Visible = False
End Sub



Private Sub Workbook_Activate()
'   Symbolleiste einblenden
On Error GoTo neu                   ' falls jemand von Hand die Symbolleiste gelöscht hat
If Application.CommandBars("Meine Symbolleiste").Visible = False Then Application. _
CommandBars("Meine Symbolleiste").Visible = True
Exit Sub
neu:                                    ' Symbolleiste neu erstellen
Workbook_Open
End Sub


Ich brauche jetzt aber neben den eigenen Makros in der eigenen Symbolleiste auch feste Funktionen wie z. B.
- öffnen
- speichern
- Seitenansicht
- rückgängig
- wiederholen
- kopieren
- einfügen
- ausschneiden
Wie bekomme ich diese Standard-Befehle von Office (inkl. Icons) in meine temporäre Symbolleiste!
Ich finde einfach keine Lösung zu diesem Problem.
Danke für die Hilfe!
Florian

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Feste Office-Befehle in eigene Symbolleiste
02.02.2009 14:38:00
D.Saster
Hallo,
füge sie mit ihrer ID ein. Dann hast du die Funktion und das Icon.
z.B.
cb.controls.add id:=23
für öffnen
- öffnen: 23
- speichern: 3
- Seitenansicht: 109
- rückgängig: 128
- wiederholen: 37
- kopieren: 19
- einfügen: 6002
- ausschneiden: 21
Gruß
Dierk
AW: Feste Office-Befehle in eigene Symbolleiste
03.02.2009 14:55:00
Florian
Hallo Dierk,
danke für deine Hilfe!
Ich hab deinen Code eingebaut, aber ich hab noch ein Problem mit den Trennlinien!
In der Zeile "Set CBC = CB.Controls.Add(ID:=128) 'Rückgängig" ist ein Fehler, der Code wird ab hier nicht mehr ausgeführt. Was hab ich hier falsch gemacht?
Ich kenn mich hier zu wenig aus, mein Latein ist hier am Ende!
Bitte um deine Hilfe!
Hier ist mein Versuch:

Private Sub Workbook_Open()
Dim CB As CommandBar
Dim CBC As CommandBarButton
Dim I As Integer
On Error Resume Next
Set CB = Application.CommandBars.Add(Name:="Menüleiste Durchschreibe", temporary:=True,  _
Position:=msoBarTop)
On Error GoTo 0
If Application.CommandBars("Menüleiste Durchschreibe").Visible = False Then
CB.Visible = True
'       Code von jinx zur Position
'       RowIndex 3 --> vor Standard-Symbolleiste
'       Rowindex 4 --> vor Formatsymbolleiste
CB.RowIndex = Application.CommandBars("Standard").RowIndex
'       Left = 0 ---> wird vor existierende Symbolleiste eingefügt
'       Left > 0 --> Wird hinter Symbolleiste angefügt
CB.Left = 0
'Application.CommandBars("Formatting").Visible = False
'Application.CommandBars("Standard").Visible = False
Set CBC = CB.Controls.Add(ID:=3) 'Speichern
Set CBC = CB.Controls.Add(ID:=4) 'Druckfenster
CBC.BeginGroup = True
Set CBC = CB.Controls.Add(ID:=109) ' Seitenansicht
Set CBC = CB.Controls.Add(ID:=19) ' Kopieren
CBC.BeginGroup = True
CB.Controls.Add ID:=6002 ' Einfügen
Set CBC = CB.Controls.Add(ID:=128) 'Rückgängig
CBC.BeginGroup = True
Set CBC = CB.Controls.Add(ID:=37) 'Wiederholen
For I = 1 To 8
Set CBC = CB.Controls.Add(Type:=msoControlButton)
With CBC
Select Case I
Case 1
ThisWorkbook.Worksheets("Icons").Shapes("Bild 1").Copy
.Caption = "Format: Auswertung"
.OnAction = "Format_Auswertung"
.Style = msoButtonIcon
.PasteFace
.BeginGroup = True
Case 2
ThisWorkbook.Worksheets("Icons").Shapes("Bild 2").Copy
.Caption = "Fußzeile"
.OnAction = "Fußzeile_einfügen"
.Style = msoButtonIcon
.PasteFace
Case 3
ThisWorkbook.Worksheets("Icons").Shapes("Bild 3").Copy
.Caption = "CSV Speichern"
.OnAction = "CSV_als_XLS_Speichern"
.Style = msoButtonIcon
.PasteFace
.BeginGroup = True
Case 4
ThisWorkbook.Worksheets("Icons").Shapes("Bild 4").Copy
.Caption = "Querformat"
.OnAction = "Querformat"
.Style = msoButtonIcon
.PasteFace
.BeginGroup = True
Case 5
ThisWorkbook.Worksheets("Icons").Shapes("Bild 5").Copy
.Caption = "Seitenrand vergrößern"
.OnAction = "Seitenrand_vergroessern"
.Style = msoButtonIcon
.PasteFace
Case 6
ThisWorkbook.Worksheets("Icons").Shapes("Bild 6").Copy
.Caption = "Automatischer Seitenumbruch"
.OnAction = "Automatischer_Seitenumbruch"
.Style = msoButtonIcon
.PasteFace
.BeginGroup = True
Case 7
ThisWorkbook.Worksheets("Icons").Shapes("Bild 7").Copy
.Caption = "Als Datum"
.OnAction = "Als_DATUM_formatieren"
.Style = msoButtonIcon
.PasteFace
.BeginGroup = True
Case 8
ThisWorkbook.Worksheets("Icons").Shapes("Bild 8").Copy
.Caption = "Als TEXT/ZAHL formatieren"
.OnAction = "Als_TEXT_formatieren"
.Style = msoButtonIcon
.PasteFace
End Select
End With
Next I
End If
End Sub


Gruß
Florian

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige