Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
664to668
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
664to668
664to668
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

eigene menüleiste aktualliesieren!

eigene menüleiste aktualliesieren!
12.09.2005 23:27:09
wuntschi
Hallo an alle,
ich habe eine Menüleiste die beim öffnen des Workbook
erstellt wird, da ich aber wärend des geöffneten
workbook die sprache wechseln kann und somit die
bezüge wo die texte herkommen ( die spalte ändert sich )
sich ändern. müßte wenn ich die sprache ändere
die menüleiste neu aufgebaut werden wie kann ich
dieses aktualiesieren der menüleiste voran treiben?
**********************************
code zur erstellung der menü leiste
***********************************

Private Sub Workbook_Open()
ModulDiverseFunktion.Tabelle_Option_einschalten
Dim SpalteSprache As Integer
Dim Text1 As String
Dim Text2 As String
Dim Text3 As String
Dim Text4 As String
Dim Text5 As String
Dim Text6 As String
Dim Text7 As String
Dim Text8 As String
Dim Text9 As String
Dim Text10 As String
If Worksheets("Optionen").Cells(1, 255).Value = 2 Then
SpalteSprache = 256
ElseIf Worksheets("Optionen").Cells(1, 255).Value = 1 Then
SpalteSprache = 255
End If
Text1 = Worksheets("Optionen").Cells(481, SpalteSprache)
Text2 = Worksheets("Optionen").Cells(482, SpalteSprache)
Text3 = Worksheets("Optionen").Cells(483, SpalteSprache)
Text4 = Worksheets("Optionen").Cells(484, SpalteSprache)
Text5 = Worksheets("Optionen").Cells(485, SpalteSprache)
Text6 = Worksheets("Optionen").Cells(486, SpalteSprache)
Text7 = Worksheets("Optionen").Cells(487, SpalteSprache)
Text8 = Worksheets("Optionen").Cells(488, SpalteSprache)
Text9 = Worksheets("Optionen").Cells(489, SpalteSprache)
Text10 = Worksheets("Optionen").Cells(490, SpalteSprache)
Text11 = Worksheets("Optionen").Cells(491, SpalteSprache)
Text12 = Worksheets("Optionen").Cells(492, SpalteSprache)
Text13 = Worksheets("Optionen").Cells(493, SpalteSprache)
Text14 = Worksheets("Optionen").Cells(494, SpalteSprache)
Text15 = Worksheets("Optionen").Cells(495, SpalteSprache)
Text16 = Worksheets("Optionen").Cells(496, SpalteSprache)
Text17 = Worksheets("Optionen").Cells(497, SpalteSprache)
Text18 = Worksheets("Optionen").Cells(498, SpalteSprache)
Text19 = Worksheets("Optionen").Cells(499, SpalteSprache)
Text20 = Worksheets("Optionen").Cells(500, SpalteSprache)
Text21 = Worksheets("Optionen").Cells(501, SpalteSprache)
Text22 = Worksheets("Optionen").Cells(502, SpalteSprache)
'******** Symbolleiste erzeugen ***********************************************'
Dim CB As CommandBar            ' Variable für Symbolleiste
Dim CBC As CommandBarButton     ' Variable für Button
Dim i As Integer                ' Variable für Schleife
On Error Resume Next
On Error Resume Next
Set CB = Application.CommandBars.Add(Name:=Text1, _
temporary:=True, Position:=msoBarTop)
' temporary:=True Symbolleiste ist flüchtig, wird beim schließen von
' Excel gelöscht
' Oben      Position:=msoBarTop
' Rechts    Position:=msoBarRight
' Links     Position:=msomsoBarLeft
' unten     Position:=msoBarBottom
If Err.Number <> 0 Then  ' Symbolleiste schon vorhanden
Application.CommandBars.Add(Name:=Text1).Visible = True
Exit Sub
End If
On Error GoTo 0
' If Application.CommandBars("FPC_Design").Visible = False Then
CB.Visible = True
'        Position der Symbolleiste vo Links
'CB.Left = 600
'        position der Symbolleiste von oben falls Position:=... nicht angegeben
CB.Top = 250
'       Wort mit Untermenü
On Error Resume Next
'       Menü löschen falls schon vorhanden
Application.CommandBars(Text1).Controls("Menü").Delete
On Error GoTo 0
With Application.CommandBars(Text1).Controls.Add(Type:=msoControlPopup)
.BeginGroup = True 'Trennlinie
On Error GoTo 0
.Caption = Text1
'           erster Menüpunkt
With .Controls.Add
.FaceId = 612
.Caption = Text2
.OnAction = "ModulSymbol.Hauptmenü"
End With
'           Zweiter Menüpunkt
With .Controls.Add
.BeginGroup = True 'Trennlinie
.FaceId = 71
.Caption = Text3
.OnAction = "ModulCoorErstellen.Tabelle_Coor_Erstellen"
End With
'          3. Menüpunkt
With .Controls.Add
.FaceId = 72
.Caption = Text4
.OnAction = "ModulSymbol.Header"
End With
'           Untermenü erzeugen:
'           vierter Menüpunktmit Untermenü
With .Controls.Add(Type:=msoControlPopup)
'               Trennlinie
.BeginGroup = True
.Caption = Text5
With .Controls.Add
.FaceId = 73
.Caption = Text5
.OnAction = "ModulSymbol.Dateneingabe"
End With
With .Controls.Add
.FaceId = 73
.Caption = Text7
.OnAction = "ModulSymbol.IPSTD"
End With
End With
'           Untermenü erzeugen:
'           sechster Menüpunktmit Untermenü
With .Controls.Add(Type:=msoControlPopup)
'               Trennlinie
.BeginGroup = True
.Caption = Text6
With .Controls.Add
.FaceId = 74
.Caption = Text8
.OnAction = "ModulSymbol.Berechnung"
End With
With .Controls.Add
.FaceId = 74
.Caption = Text9
.OnAction = "ModulSymbol.ohneBerechnung"
End With
End With
'           siebter Menüpunkt
With .Controls.Add
.BeginGroup = True 'Trennlinie
.FaceId = 75
.Caption = Text10
.OnAction = "ModulSymbol.Nullrechnen"
End With
'           Achter  Menüpunkt
With .Controls.Add
.FaceId = 76
.Caption = Text11
.OnAction = "ModulSymbol.layout1"
End With
'           Neunter  Menüpunkt
With .Controls.Add
.FaceId = 77
.Caption = Text12
.OnAction = "ModulSymbol.layout2"
End With
'zehnter Menüpunkt
With .Controls.Add
.FaceId = 78
.Caption = Text13
.OnAction = "ModulSymbol.zusatzseiten"
End With
'elfter Menüpunkt
With .Controls.Add
.FaceId = 79
.Caption = Text14
.OnAction = "ModulSpeichern.speichern_ohne_Makros"
End With
'           Untermenü erzeugen:
'           dritter Menüpunktmit Untermenü
With .Controls.Add(Type:=msoControlPopup)
'               Trennlinie
.BeginGroup = True
.Caption = Text15
With .Controls.Add
.FaceId = 47
.Caption = Text16
.OnAction = "ModulDel.Layout_delete"
End With
With .Controls.Add
.FaceId = 47
.Caption = Text17
.OnAction = "ModulSymbol.Coor_löschen"
End With
With .Controls.Add
.FaceId = 47
.Caption = Text18
.OnAction = "ModulSymbol.Header_löschen"
End With
With .Controls.Add
.FaceId = 47
.Caption = Text19
.OnAction = "ModulSymbol.Pad_löschen"
End With
With .Controls.Add
.FaceId = 47
.Caption = Text20
.OnAction = "ModulSymbol.CoorDaten_löschen"
End With
With .Controls.Add
.FaceId = 47
.Caption = Text21
.OnAction = "ModulDel.alle_nicht_wichtigen"
End With
End With
With .Controls.Add
.BeginGroup = True 'Trennlinie
.FaceId = 20
.Caption = Text22
.OnAction = "ModulSymbol.option_öffnen"
End With '
End With
ModulDiverseFunktion.neu_symbolleiste
End Sub


Private Sub Workbook_Deactivate()
'    Aktion beim Wechsel der Datei
'    Schaltflächen nicht auswählbar bei Daieiwechsel
'    Dim I as Byte
'    With Application.CommandBars("FPC_Design")
'        For I = 1 To 15
'            .Controls(I).Enabled = False
'        Next I
'    End With
'   Symbolleiste ausblenden bei Dateiwechsel
On Error Resume Next
If Application.CommandBars("FPC_Design").Visible = True Then
Application.CommandBars("FPC_Design").Visible = False
End If
End Sub


Private Sub Workbook_Activate()
'   Aktion bei aktivierung dieser Datei
On Error GoTo neu
If Application.CommandBars("FPC_Design").Visible = False Then
Application.CommandBars("FPC_Design").Visible = True
End If
Exit Sub
neu:
Workbook_Open
End Sub

'

Private Sub Workbook_BeforeClose(Cancel As Boolean)
''   temporary:=false, Symbolleiste muß gelöscht werden
''   bei der jetzigen Variante wird die Symbolleiste
''   beim schliessen von Excel gelöscht
''   Aktion beim schliessen der Datei
'    On Error Resume Next
'    Application.CommandBars("FPC_Design").Delete
'End Sub


Private Sub Workbook_SheetSelectionChange(ByVal sh As Object, ByVal Target As Excel.Range)
'   Aktion bei Auswahl einer Zelle in dieser Datei
'   Symbolleiste einblenden falls Sie jemand ausgeblendet hat bzw.
On Error GoTo neu
If Application.CommandBars("FPC_Design").Visible = False Then
Application.CommandBars("FPC_Design").Visible = True
End If
Exit Sub
neu:
Workbook_Open
End Sub

vielen Dank
gruß
wuntschi

9
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: eigene menüleiste aktualliesieren!
13.09.2005 00:25:20
Nepumuk
Hi,
das Makro zum erstellen der Titelleiste hat im Klassenmodul der Mappe nichts verloren. Da komm ein Aufruf rein, der das Commandbarmakro ausführt. Das verschiebst du in ein Standardmodul.
Wozu der Umweg, die Werte erst in Stringvariable einzulesen, nur um sie als Caption für deine Controls zu verwenden? Wenn du das schon machst, dann benutze ein Array. Da musst du nur eine Variable deklarieren und nicht 22. Wobei du bei der zehnten aufgehört hast und die anderen Excel überlässt.
Das einfachste wäre, gleich zwei Commandbars, das kannst du in einer Schleife machen, anzulegen und nur die mit der richtigen Sprache einzublenden.
Ansonsten ist mir dein Code zu wirr. :-)
Gruß
Nepumuk

Anzeige
AW: eigene menüleiste aktualliesieren!
13.09.2005 11:06:27
wuntschi
Hallo Nepumuk,
Vielen Dank für den Tip,
mit dem das man ja zwei Menüleisten erstellen kann
und die entsprechende auswählt!
Habe mein Code auch ein wenig aufgeräumt!
Aber das mit dem deklarieren verstehe ich noch nicht(Array und so)!
Vieleicht hast du da noch ein Tip oder du sagst mir wie es richtig ist!
*************** Hier meine Lösung **********************

Private Sub Workbook_Open()
ModulDiverseFunktion.menü_deutsch
ModulDiverseFunktion.menü_englisch
End Sub


Private Sub Workbook_Deactivate()
ModulDiverseFunktion.Tabelle_Option_einschalten
If Application.CommandBars("FPC_Design_D").Visible = True Then
Application.CommandBars("FPC_Design_D").Visible = False
End If
If Application.CommandBars("FPC_Design_E").Visible = True Then
Application.CommandBars("FPC_Design_E").Visible = False
End If
ModulDiverseFunktion.Tabelle_option_ausschalten
End Sub


Private Sub Workbook_Activate()
ModulDiverseFunktion.Tabelle_Option_einschalten
'********************************* Deutsch **************************'
If Worksheets("Optionen").Cells(1, 255) = 1 Then
Application.CommandBars("FPC_Design_D").Visible = True
Application.CommandBars("FPC_Design_E").Visible = False
End If
' ******************* Englisch ****************************************'
If Worksheets("Optionen").Cells(1, 255) = 2 Then
Application.CommandBars("FPC_Design_E").Visible = True
Application.CommandBars("FPC_Design_D").Visible = False
End If
ModulDiverseFunktion.Tabelle_option_ausschalten
End Sub

***************** Modul DiverseFunkltion *********************

Sub menü_deutsch()

ModulDiverseFunktion.Tabelle_Option_einschalten
Dim SpalteSprache As Integer
Dim Text1 As String
Dim Text2 As String
Dim Text3 As String
Dim Text4 As String
Dim Text5 As String
Dim Text6 As String
Dim Text7 As String
Dim Text8 As String
Dim Text9 As String
Dim Text10 As String
Dim Text11 As String
Dim Text12 As String
Dim Text13 As String
Dim Text14 As String
Dim Text15 As String
Dim Text16 As String
Dim Text17 As String
Dim Text18 As String
Dim Text19 As String
Dim Text20 As String
Dim Text21 As String
Dim Text22 As String
SpalteSprache = 255

Text1 = Worksheets("Optionen").Cells(481, SpalteSprache)
Text2 = Worksheets("Optionen").Cells(482, SpalteSprache)
Text3 = Worksheets("Optionen").Cells(483, SpalteSprache)
Text4 = Worksheets("Optionen").Cells(484, SpalteSprache)
Text5 = Worksheets("Optionen").Cells(485, SpalteSprache)
Text6 = Worksheets("Optionen").Cells(486, SpalteSprache)
Text7 = Worksheets("Optionen").Cells(487, SpalteSprache)
Text8 = Worksheets("Optionen").Cells(488, SpalteSprache)
Text9 = Worksheets("Optionen").Cells(489, SpalteSprache)
Text10 = Worksheets("Optionen").Cells(490, SpalteSprache)
Text11 = Worksheets("Optionen").Cells(491, SpalteSprache)
Text12 = Worksheets("Optionen").Cells(492, SpalteSprache)
Text13 = Worksheets("Optionen").Cells(493, SpalteSprache)
Text14 = Worksheets("Optionen").Cells(494, SpalteSprache)
Text15 = Worksheets("Optionen").Cells(495, SpalteSprache)
Text16 = Worksheets("Optionen").Cells(496, SpalteSprache)
Text17 = Worksheets("Optionen").Cells(497, SpalteSprache)
Text18 = Worksheets("Optionen").Cells(498, SpalteSprache)
Text19 = Worksheets("Optionen").Cells(499, SpalteSprache)
Text20 = Worksheets("Optionen").Cells(500, SpalteSprache)
Text21 = Worksheets("Optionen").Cells(501, SpalteSprache)
Text22 = Worksheets("Optionen").Cells(502, SpalteSprache)


'******************************************************************************'
'******** Symbolleiste erzeugen ***********************************************'
'******************************************************************************'

Dim CB As CommandBar ' Variable für Symbolleiste
Dim CBC As CommandBarButton ' Variable für Button
Dim i As Integer ' Variable für Schleife

On Error Resume Next
On Error Resume Next
Set CB = Application.CommandBars.Add(Name:=Text1, _
temporary:=True, Position:=msoBarTop)
' temporary:=True Symbolleiste ist flüchtig, wird beim schließen von
' Excel gelöscht
' Oben Position:=msoBarTop
' Rechts Position:=msoBarRight
' Links Position:=msomsoBarLeft
' unten Position:=msoBarBottom
If Err.Number 0 Then ' Symbolleiste schon vorhanden
Application.CommandBars.Add(Name:=Text1).Visible = True
Exit Sub
End If
On Error GoTo 0
' If Application.CommandBars("FPC_Design").Visible = False Then
CB.Visible = True
' Position der Symbolleiste vo Links
'CB.Left = 600
' position der Symbolleiste von oben falls Position:=... nicht angegeben
CB.Top = 250

' Wort mit Untermenü
On Error Resume Next
' Menü löschen falls schon vorhanden
Application.CommandBars(Text1).Controls("Menü").Delete
On Error GoTo 0

With Application.CommandBars(Text1).Controls.Add(Type:=msoControlPopup)
.BeginGroup = True 'Trennlinie
On Error GoTo 0
.Caption = Text1
' erster Menüpunkt
With .Controls.Add
.FaceId = 612
.Caption = Text2
.OnAction = "ModulSymbol.Hauptmenü"
End With
' Zweiter Menüpunkt
With .Controls.Add
.BeginGroup = True 'Trennlinie
.FaceId = 71
.Caption = Text3
.OnAction = "ModulCoorErstellen.Tabelle_Coor_Erstellen"
End With
' 3. Menüpunkt
With .Controls.Add
.FaceId = 72
.Caption = Text4
.OnAction = "ModulSymbol.Header"
End With
' Untermenü erzeugen:
' vierter Menüpunktmit Untermenü
With .Controls.Add(Type:=msoControlPopup)

' Trennlinie
.BeginGroup = True
.Caption = Text5
With .Controls.Add
.FaceId = 73
.Caption = Text5
.OnAction = "ModulSymbol.Dateneingabe"
End With
With .Controls.Add
.FaceId = 73
.Caption = Text7
.OnAction = "ModulSymbol.IPSTD"
End With

End With
' Untermenü erzeugen:
' sechster Menüpunktmit Untermenü
With .Controls.Add(Type:=msoControlPopup)

' Trennlinie
.BeginGroup = True
.Caption = Text6
With .Controls.Add
.FaceId = 74
.Caption = Text8
.OnAction = "ModulSymbol.Berechnung"
End With
With .Controls.Add
.FaceId = 74
.Caption = Text9
.OnAction = "ModulSymbol.ohneBerechnung"
End With

End With
' siebter Menüpunkt
With .Controls.Add
.BeginGroup = True 'Trennlinie
.FaceId = 75
.Caption = Text10
.OnAction = "ModulSymbol.Nullrechnen"
End With
' Achter Menüpunkt
With .Controls.Add
.FaceId = 76
.Caption = Text11
.OnAction = "ModulSymbol.layout1"
End With
' Neunter Menüpunkt

With .Controls.Add
.FaceId = 77
.Caption = Text12
.OnAction = "ModulSymbol.layout2"
End With

'zehnter Menüpunkt

With .Controls.Add
.FaceId = 78
.Caption = Text13
.OnAction = "ModulSymbol.zusatzseiten"
End With
'elfter Menüpunkt
With .Controls.Add
.FaceId = 79
.Caption = Text14
.OnAction = "ModulSpeichern.speichern_ohne_Makros"
End With
' Untermenü erzeugen:
' dritter Menüpunktmit Untermenü
With .Controls.Add(Type:=msoControlPopup)
' Trennlinie
.BeginGroup = True
.Caption = Text15

With .Controls.Add
.FaceId = 47
.Caption = Text16
.OnAction = "ModulDel.Layout_delete"
End With

With .Controls.Add
.FaceId = 47
.Caption = Text17
.OnAction = "ModulSymbol.Coor_löschen"
End With

With .Controls.Add
.FaceId = 47
.Caption = Text18
.OnAction = "ModulSymbol.Header_löschen"
End With

With .Controls.Add
.FaceId = 47
.Caption = Text19
.OnAction = "ModulSymbol.Pad_löschen"
End With

With .Controls.Add
.FaceId = 47
.Caption = Text20
.OnAction = "ModulSymbol.CoorDaten_löschen"
End With

With .Controls.Add
.FaceId = 47
.Caption = Text21
.OnAction = "ModulDel.alle_nicht_wichtigen"
End With

End With
With .Controls.Add
.BeginGroup = True 'Trennlinie
.FaceId = 20
.Caption = Text22
.OnAction = "ModulSymbol.option_öffnen"
End With '
End With
ModulDiverseFunktion.Tabelle_option_ausschalten
End Sub


Sub menü_englisch()
ModulDiverseFunktion.Tabelle_Option_einschalten
Dim SpalteSprache As Integer
Dim Text1 As String
Dim Text2 As String
Dim Text3 As String
Dim Text4 As String
Dim Text5 As String
Dim Text6 As String
Dim Text7 As String
Dim Text8 As String
Dim Text9 As String
Dim Text10 As String
Dim Text11 As String
Dim Text12 As String
Dim Text13 As String
Dim Text14 As String
Dim Text15 As String
Dim Text16 As String
Dim Text17 As String
Dim Text18 As String
Dim Text19 As String
Dim Text20 As String
Dim Text21 As String
Dim Text22 As String
SpalteSprache = 256

Text1 = Worksheets("Optionen").Cells(481, SpalteSprache)
Text2 = Worksheets("Optionen").Cells(482, SpalteSprache)
Text3 = Worksheets("Optionen").Cells(483, SpalteSprache)
Text4 = Worksheets("Optionen").Cells(484, SpalteSprache)
Text5 = Worksheets("Optionen").Cells(485, SpalteSprache)
Text6 = Worksheets("Optionen").Cells(486, SpalteSprache)
Text7 = Worksheets("Optionen").Cells(487, SpalteSprache)
Text8 = Worksheets("Optionen").Cells(488, SpalteSprache)
Text9 = Worksheets("Optionen").Cells(489, SpalteSprache)
Text10 = Worksheets("Optionen").Cells(490, SpalteSprache)
Text11 = Worksheets("Optionen").Cells(491, SpalteSprache)
Text12 = Worksheets("Optionen").Cells(492, SpalteSprache)
Text13 = Worksheets("Optionen").Cells(493, SpalteSprache)
Text14 = Worksheets("Optionen").Cells(494, SpalteSprache)
Text15 = Worksheets("Optionen").Cells(495, SpalteSprache)
Text16 = Worksheets("Optionen").Cells(496, SpalteSprache)
Text17 = Worksheets("Optionen").Cells(497, SpalteSprache)
Text18 = Worksheets("Optionen").Cells(498, SpalteSprache)
Text19 = Worksheets("Optionen").Cells(499, SpalteSprache)
Text20 = Worksheets("Optionen").Cells(500, SpalteSprache)
Text21 = Worksheets("Optionen").Cells(501, SpalteSprache)
Text22 = Worksheets("Optionen").Cells(502, SpalteSprache)


'******************************************************************************'
'******** Symbolleiste erzeugen ***********************************************'
'******************************************************************************'

Dim CB As CommandBar ' Variable für Symbolleiste
Dim CBC As CommandBarButton ' Variable für Button
Dim i As Integer ' Variable für Schleife

On Error Resume Next
On Error Resume Next
Set CB = Application.CommandBars.Add(Name:=Text1, _
temporary:=True, Position:=msoBarTop)
' temporary:=True Symbolleiste ist flüchtig, wird beim schließen von
' Excel gelöscht
' Oben Position:=msoBarTop
' Rechts Position:=msoBarRight
' Links Position:=msomsoBarLeft
' unten Position:=msoBarBottom
If Err.Number 0 Then ' Symbolleiste schon vorhanden
Application.CommandBars.Add(Name:=Text1).Visible = True
Exit Sub
End If
On Error GoTo 0
' If Application.CommandBars("FPC_Design").Visible = False Then
CB.Visible = True
' Position der Symbolleiste vo Links
'CB.Left = 600
' position der Symbolleiste von oben falls Position:=... nicht angegeben
CB.Top = 250

' Wort mit Untermenü
On Error Resume Next
' Menü löschen falls schon vorhanden
Application.CommandBars(Text1).Controls("Menü").Delete
On Error GoTo 0

With Application.CommandBars(Text1).Controls.Add(Type:=msoControlPopup)
.BeginGroup = True 'Trennlinie
On Error GoTo 0
.Caption = Text1
' erster Menüpunkt
With .Controls.Add
.FaceId = 612
.Caption = Text2
.OnAction = "ModulSymbol.Hauptmenü"
End With
' Zweiter Menüpunkt
With .Controls.Add
.BeginGroup = True 'Trennlinie
.FaceId = 71
.Caption = Text3
.OnAction = "ModulCoorErstellen.Tabelle_Coor_Erstellen"
End With
' 3. Menüpunkt
With .Controls.Add
.FaceId = 72
.Caption = Text4
.OnAction = "ModulSymbol.Header"
End With
' Untermenü erzeugen:
' vierter Menüpunktmit Untermenü
With .Controls.Add(Type:=msoControlPopup)

' Trennlinie
.BeginGroup = True
.Caption = Text5
With .Controls.Add
.FaceId = 73
.Caption = Text5
.OnAction = "ModulSymbol.Dateneingabe"
End With
With .Controls.Add
.FaceId = 73
.Caption = Text7
.OnAction = "ModulSymbol.IPSTD"
End With

End With
' Untermenü erzeugen:
' sechster Menüpunktmit Untermenü
With .Controls.Add(Type:=msoControlPopup)

' Trennlinie
.BeginGroup = True
.Caption = Text6
With .Controls.Add
.FaceId = 74
.Caption = Text8
.OnAction = "ModulSymbol.Berechnung"
End With
With .Controls.Add
.FaceId = 74
.Caption = Text9
.OnAction = "ModulSymbol.ohneBerechnung"
End With

End With
' siebter Menüpunkt
With .Controls.Add
.BeginGroup = True 'Trennlinie
.FaceId = 75
.Caption = Text10
.OnAction = "ModulSymbol.Nullrechnen"
End With
' Achter Menüpunkt
With .Controls.Add
.FaceId = 76
.Caption = Text11
.OnAction = "ModulSymbol.layout1"
End With
' Neunter Menüpunkt

With .Controls.Add
.FaceId = 77
.Caption = Text12
.OnAction = "ModulSymbol.layout2"
End With

'zehnter Menüpunkt

With .Controls.Add
.FaceId = 78
.Caption = Text13
.OnAction = "ModulSymbol.zusatzseiten"
End With
'elfter Menüpunkt
With .Controls.Add
.FaceId = 79
.Caption = Text14
.OnAction = "ModulSpeichern.speichern_ohne_Makros"
End With
' Untermenü erzeugen:
' dritter Menüpunktmit Untermenü
With .Controls.Add(Type:=msoControlPopup)
' Trennlinie
.BeginGroup = True
.Caption = Text15

With .Controls.Add
.FaceId = 47
.Caption = Text16
.OnAction = "ModulDel.Layout_delete"
End With

With .Controls.Add
.FaceId = 47
.Caption = Text17
.OnAction = "ModulSymbol.Coor_löschen"
End With

With .Controls.Add
.FaceId = 47
.Caption = Text18
.OnAction = "ModulSymbol.Header_löschen"
End With

With .Controls.Add
.FaceId = 47
.Caption = Text19
.OnAction = "ModulSymbol.Pad_löschen"
End With

With .Controls.Add
.FaceId = 47
.Caption = Text20
.OnAction = "ModulSymbol.CoorDaten_löschen"
End With

With .Controls.Add
.FaceId = 47
.Caption = Text21
.OnAction = "ModulDel.alle_nicht_wichtigen"
End With

End With
With .Controls.Add
.BeginGroup = True 'Trennlinie
.FaceId = 20
.Caption = Text22
.OnAction = "ModulSymbol.option_öffnen"
End With '
End With
ModulDiverseFunktion.Tabelle_option_ausschalten
End Sub
************************** ENDE **********************************
gruß
wuntschi
Anzeige
AW: eigene menüleiste aktualliesieren!
13.09.2005 11:19:26
Nepumuk
Hallo wuntschi,
aus dem:
Public Sub wuntschi()
    Dim Text1 As String
    Dim Text2 As String
    Dim Text3 As String
    Dim Text4 As String
    Dim Text5 As String
    Dim Text6 As String
    Dim Text7 As String
    Dim Text8 As String
    Dim Text9 As String
    Dim Text10 As String
    Dim Text11 As String
    Dim Text12 As String
    Dim Text13 As String
    Dim Text14 As String
    Dim Text15 As String
    Dim Text16 As String
    Dim Text17 As String
    Dim Text18 As String
    Dim Text19 As String
    Dim Text20 As String
    Dim Text21 As String
    Dim Text22 As String
    Dim SpalteSprache As Integer
    
    SpalteSprache = 255
    
    Text1 = Worksheets("Optionen").Cells(481, SpalteSprache)
    Text2 = Worksheets("Optionen").Cells(482, SpalteSprache)
    Text3 = Worksheets("Optionen").Cells(483, SpalteSprache)
    Text4 = Worksheets("Optionen").Cells(484, SpalteSprache)
    Text5 = Worksheets("Optionen").Cells(485, SpalteSprache)
    Text6 = Worksheets("Optionen").Cells(486, SpalteSprache)
    Text7 = Worksheets("Optionen").Cells(487, SpalteSprache)
    Text8 = Worksheets("Optionen").Cells(488, SpalteSprache)
    Text9 = Worksheets("Optionen").Cells(489, SpalteSprache)
    Text10 = Worksheets("Optionen").Cells(490, SpalteSprache)
    Text11 = Worksheets("Optionen").Cells(491, SpalteSprache)
    Text12 = Worksheets("Optionen").Cells(492, SpalteSprache)
    Text13 = Worksheets("Optionen").Cells(493, SpalteSprache)
    Text14 = Worksheets("Optionen").Cells(494, SpalteSprache)
    Text15 = Worksheets("Optionen").Cells(495, SpalteSprache)
    Text16 = Worksheets("Optionen").Cells(496, SpalteSprache)
    Text17 = Worksheets("Optionen").Cells(497, SpalteSprache)
    Text18 = Worksheets("Optionen").Cells(498, SpalteSprache)
    Text19 = Worksheets("Optionen").Cells(499, SpalteSprache)
    Text20 = Worksheets("Optionen").Cells(500, SpalteSprache)
    Text21 = Worksheets("Optionen").Cells(501, SpalteSprache)
    Text22 = Worksheets("Optionen").Cells(502, SpalteSprache)
End Sub

Mache ich das:
Public Sub Nepumuk()
    Dim strText(1 To 22) As String
    Dim lngZeileSprache As Long, intSpalteSprache As Integer
    intSpalteSprache = 255
    For lngZeileSprache = 481 To 502
        strText(lngZeileSprache - 480) = Worksheets("Optionen") _
            .Cells(lngZeileSprache, intSpalteSprache)
    Next
End Sub

Die Zuweisung der Texte an die Caption erfolgt dann Beispielsweise so:
.Caption = strText(5)
Gruß
Nepumuk

Anzeige
AW: eigene menüleiste aktualliesieren!
15.09.2005 02:58:00
wuntschi
Hallo Nepumuk,
danke für die antwort,
wie kommt es das du vor den Variable immer abgekürzt
die art der Variablen schreibst,
ist das ein trick oder wo kommt das her?
gruß
wuntschi
AW: eigene menüleiste aktualliesieren!
15.09.2005 03:14:47
Nepumuk
Hallo wuntschi,
1. Weil ich dann ich Zeile 5.000 immer noch weiß, was für ein Variablentyp das ist. Wenn mal ein Makro wegen eines Fehlers aussteigt, sehe ich meistens sofort warum.
2. Weil es sonst passieren kann, dass du einer Variabel einen Namen gibt, der als Schlüsselwort in VBA fungiert.
3. Weil das internationale Programmierkonventionen sind.
Das ganze nennt sich ungarische Notation. Ein kleine Übersicht findest du hier:
http://www.it-academy.cc/content/article_browse.php?ID=995
Gruß
Nepumuk

Anzeige
AW: eigene menüleiste aktualliesieren!
15.09.2005 16:44:37
wuntschi
Hallo Nepumuk,
viele Dank für die Erklärung!
Werde mich in Zzukunft auch versuchen an diese
Bezeichnung von Variabeln.
Kannst du evtl. nochmal schaun was, bei meinen
Code falsch ist!
Gruß
wuntschi
AW: eigene menüleiste aktualliesieren!
15.09.2005 03:24:42
wuntschi
Hallo Nepumuk,
ich habe deine Lösung übernehmen müssen,
das funtzt aber nicht.
mein Code sieht jetzt wie folgt aus!
ModulDiverseFunktion.Tabelle_Option_einschalten
Dim strText(1 To 22) As String
Dim lngZeileSprache As Long, intSpalteSprache As Integer
intSpalteSprache = 255
For lngZeileSprache = 481 To 502
strText(lngZeileSprache - 480) = Worksheets("Optionen") _
.Cells(lngZeileSprache, intSpalteSprache).Value
Next

'******************************************************************************'
'******** Symbolleiste erzeugen ***********************************************'
'******************************************************************************'

Dim CB As CommandBar ' Variable für Symbolleiste
Dim CBC As CommandBarButton ' Variable für Button
Dim i As Integer ' Variable für Schleife

On Error Resume Next
On Error Resume Next
Set CB = Application.CommandBars.Add(Name:=strText(1), _
temporary:=True, Position:=msoBarTop)
' temporary:=True Symbolleiste ist flüchtig, wird beim schließen von
' Excel gelöscht
' Oben Position:=msoBarTop
' Rechts Position:=msoBarRight
' Links Position:=msomsoBarLeft
' unten Position:=msoBarBottom
If Err.Number 0 Then ' Symbolleiste schon vorhanden
Application.CommandBars.Add(Name:=strText(1)).Visible = True
Exit Sub
End If
On Error GoTo 0
' If Application.CommandBars("FPC_Design").Visible = False Then
CB.Visible = True
' Position der Symbolleiste vo Links
'CB.Left = 600
' position der Symbolleiste von oben falls Position:=... nicht angegeben
CB.Top = 250

' Wort mit Untermenü
On Error Resume Next
' Menü löschen falls schon vorhanden
Application.CommandBars(strText(1)).Controls("Menü").Delete
On Error GoTo 0

With Application.CommandBars(strText1).Controls.Add(Type:=msoControlPopup)
.BeginGroup = True 'Trennlinie
On Error GoTo 0
.Caption = strText(1)
' erster Menüpunkt
With .Controls.Add
.FaceId = 612
.Caption = strText(2)
.OnAction = "ModulSymbol.Hauptmenü"
End With
' Zweiter Menüpunkt
With .Controls.Add
.BeginGroup = True 'Trennlinie
.FaceId = 71
.Caption = strText(3)
.OnAction = "ModulCoorErstellen.Tabelle_Coor_Erstellen"
End With
' 3. Menüpunkt
With .Controls.Add
.FaceId = 72
.Caption = strText(4)
.OnAction = "ModulSymbol.Header"
End With
' Untermenü erzeugen:
' vierter Menüpunktmit Untermenü
With .Controls.Add(Type:=msoControlPopup)

' Trennlinie
.BeginGroup = True
.Caption = strText(5)
With .Controls.Add
.FaceId = 73
.Caption = strText(5)
.OnAction = "ModulSymbol.Dateneingabe"
End With
With .Controls.Add
.FaceId = 73
.Caption = strText(7)
.OnAction = "ModulSymbol.IPSTD"
End With

End With
' Untermenü erzeugen:
' sechster Menüpunktmit Untermenü
With .Controls.Add(Type:=msoControlPopup)

' Trennlinie
.BeginGroup = True
.Caption = strText(6)
With .Controls.Add
.FaceId = 74
.Caption = strText(8)
.OnAction = "ModulSymbol.Berechnung"
End With
With .Controls.Add
.FaceId = 74
.Caption = strText(9)
.OnAction = "ModulSymbol.ohneBerechnung"
End With

End With
' siebter Menüpunkt
With .Controls.Add
.BeginGroup = True 'Trennlinie
.FaceId = 75
.Caption = strText(10)
.OnAction = "ModulSymbol.NR"
End With
' Achter Menüpunkt
With .Controls.Add
.FaceId = 76
.Caption = strText(11)
.OnAction = "ModulSymbol.layout1"
End With
' Neunter Menüpunkt

With .Controls.Add
.FaceId = 77
.Caption = strText(12)
.OnAction = "ModulSymbol.layout2"
End With

'zehnter Menüpunkt

With .Controls.Add
.FaceId = 78
.Caption = strText(13)
.OnAction = "ModulSymbol.zusatzseiten"
End With
'elfter Menüpunkt
With .Controls.Add
.FaceId = 79
.Caption = strText(14)
.OnAction = "ModulSpeichern.speichern_ohne_Makros"
End With
' Untermenü erzeugen:
' dritter Menüpunktmit Untermenü
With .Controls.Add(Type:=msoControlPopup)
' Trennlinie
.BeginGroup = True
.Caption = strText(15)

With .Controls.Add
.FaceId = 47
.Caption = strText(16)
.OnAction = "ModulDel.Layout_delete"
End With

With .Controls.Add
.FaceId = 47
.Caption = strText(17)
.OnAction = "ModulSymbol.Coor_löschen"
End With

With .Controls.Add
.FaceId = 47
.Caption = strText(18)
.OnAction = "ModulSymbol.Header_löschen"
End With

With .Controls.Add
.FaceId = 47
.Caption = strText(19)
.OnAction = "ModulSymbol.Pad_löschen"
End With

With .Controls.Add
.FaceId = 47
.Caption = strText(20)
.OnAction = "ModulSymbol.CoorDaten_löschen"
End With

With .Controls.Add
.FaceId = 47
.Caption = strText(21)
.OnAction = "ModulDel.alle_nicht_wichtigen"
End With

End With
With .Controls.Add
.BeginGroup = True 'Trennlinie
.FaceId = 20
.Caption = strText(22)
.OnAction = "ModulSymbol.option_öffnen"
End With '
End With
ModulDiverseFunktion.Tabelle_option_ausschalten
gruß
wuntschi
Anzeige
AW: eigene menüleiste aktualliesieren!
15.09.2005 17:33:57
wuntschi
Hallo kann mir jemand helfen?
gruß
wuntschi
AW: eigene menüleiste aktualliesieren!
15.09.2005 23:59:48
wuntschi
Hallo Nepumuk,
ich habe den Fehler selber gefunden,
ich habe in folgender Zeile die Klammern bei strText(1)
vergessen
da stand
With Application.CommandBars(strText1).Controls.Add(Type:=msoControlPopup)
und
With Application.CommandBars(strText(1)).Controls.Add(Type:=msoControlPopup)
ist richtig!
Vielen Dank!
gruß
wuntschi

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige