Thema Datum  Von Nutzer Rating
Antwort
Rot Kontextmenü Hilfe
08.07.2021 07:36:50 SmileStyle
NotSolved
08.07.2021 09:20:09 Gast79811
NotSolved
08.07.2021 09:21:30 SmileStyle
NotSolved
08.07.2021 09:23:58 Gast66185
NotSolved
08.07.2021 09:32:12 SmileStyle
NotSolved
08.07.2021 09:40:23 Gast57885
NotSolved
08.07.2021 09:42:27 Gast27964
NotSolved
08.07.2021 09:45:59 Gast53676
NotSolved
08.07.2021 09:52:01 Gast76879
NotSolved
08.07.2021 11:33:40 Gast4572
NotSolved
08.07.2021 11:48:05 Gast4572
NotSolved
08.07.2021 12:29:56 SmileStyle
NotSolved
08.07.2021 12:45:47 Gast4572
NotSolved
08.07.2021 12:51:09 Mase
NotSolved
08.07.2021 14:50:00 SmileStyle
NotSolved
12.07.2021 08:06:36 Gast60839
NotSolved
12.07.2021 13:05:39 Gast67685
NotSolved
12.07.2021 13:51:01 SmileStyle
NotSolved
12.07.2021 17:01:12 Gast31774
NotSolved
13.07.2021 09:49:11 SmileStyle
NotSolved
13.07.2021 12:09:49 Gast31774
NotSolved
13.07.2021 12:14:26 Gast24006
NotSolved
13.07.2021 12:25:41 Gast31774
NotSolved
13.07.2021 12:40:32 Gast80767
NotSolved
13.07.2021 13:08:25 Gast38241
NotSolved
13.07.2021 14:17:30 Gast47257
NotSolved
13.07.2021 14:24:39 SmileStyle
NotSolved
13.07.2021 19:38:48 Gast10209
NotSolved
16.07.2021 06:18:11 SmileStyle
NotSolved
18.07.2021 19:21:12 Gast50788
NotSolved
19.07.2021 08:16:44 SmileStyle
NotSolved
19.07.2021 22:11:38 Gast36161
NotSolved
20.07.2021 08:42:14 SmileStyle
NotSolved
20.07.2021 22:34:34 Gast62425
NotSolved
21.07.2021 06:42:03 SmileStyle
NotSolved

Ansicht des Beitrags:
Von:
SmileStyle
Datum:
08.07.2021 07:36:50
Views:
1304
Rating: Antwort:
  Ja
Thema:
Kontextmenü Hilfe

Guten Morgen,

bin nicht sehr bewandert was VBA angeht und habe gerade einen Code vor mir liegen den ich umschreiben möchte.

Public Sub CreateCommandBar()

  Dim objCommandBar As CommandBar
  Dim objCommandBarButton As CommandBarButton
  Dim objName As Name
  Dim lngIndex As Long

  Call DeleteCommandBar

  Set objCommandBar = CommandBars.Add(Name:=CONTEXT_MENU, _
  Position:=msoBarPopup, Temporary:=True)

  For lngIndex = 1 To 25

      For Each objName In ThisWorkbook.Names

          If objName.Name = "AbwK" & CStr(lngIndex) Then Exit For

      Next

      If Not objName Is Nothing Then

         If Not IsError(Evaluate(objName.RefersTo)) Then

            If Not IsEmpty(Range(objName.Name).Value) Then

               Set objCommandBarButton = objCommandBar.Controls.Add(Type:=msoControlButton)

               With objCommandBarButton

                   .Caption = Range(objName.Name).Value
                   .OnAction = "'Färbe """ & objName.Name & "k" & """'"

               End With
            End If
         End If
      End If
  Next

  Set objCommandBarButton = Nothing
  Set objCommandBar = Nothing
  Set objName = Nothing

End Sub

 

Unzwar erstellt er mir ein Kontextmenü mit Einträgen die ich mit den Bereichsnamen AbwK1-25 benannt habe. Jetzt möchte ich das auf .Caption diese Auswahl bleibt also da kann der Code so bleiben, aber für .OnAction habe ich weitere Bereichsnamen definiert AbwKk1-25 diese soll er dort dann aufrufen. 

Wenn ich & "k" mache setzt er mir das immer dahinter = AbwK20k

Kann mir wer helfen?

 

Gruß Smile


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
Rot Kontextmenü Hilfe
08.07.2021 07:36:50 SmileStyle
NotSolved
08.07.2021 09:20:09 Gast79811
NotSolved
08.07.2021 09:21:30 SmileStyle
NotSolved
08.07.2021 09:23:58 Gast66185
NotSolved
08.07.2021 09:32:12 SmileStyle
NotSolved
08.07.2021 09:40:23 Gast57885
NotSolved
08.07.2021 09:42:27 Gast27964
NotSolved
08.07.2021 09:45:59 Gast53676
NotSolved
08.07.2021 09:52:01 Gast76879
NotSolved
08.07.2021 11:33:40 Gast4572
NotSolved
08.07.2021 11:48:05 Gast4572
NotSolved
08.07.2021 12:29:56 SmileStyle
NotSolved
08.07.2021 12:45:47 Gast4572
NotSolved
08.07.2021 12:51:09 Mase
NotSolved
08.07.2021 14:50:00 SmileStyle
NotSolved
12.07.2021 08:06:36 Gast60839
NotSolved
12.07.2021 13:05:39 Gast67685
NotSolved
12.07.2021 13:51:01 SmileStyle
NotSolved
12.07.2021 17:01:12 Gast31774
NotSolved
13.07.2021 09:49:11 SmileStyle
NotSolved
13.07.2021 12:09:49 Gast31774
NotSolved
13.07.2021 12:14:26 Gast24006
NotSolved
13.07.2021 12:25:41 Gast31774
NotSolved
13.07.2021 12:40:32 Gast80767
NotSolved
13.07.2021 13:08:25 Gast38241
NotSolved
13.07.2021 14:17:30 Gast47257
NotSolved
13.07.2021 14:24:39 SmileStyle
NotSolved
13.07.2021 19:38:48 Gast10209
NotSolved
16.07.2021 06:18:11 SmileStyle
NotSolved
18.07.2021 19:21:12 Gast50788
NotSolved
19.07.2021 08:16:44 SmileStyle
NotSolved
19.07.2021 22:11:38 Gast36161
NotSolved
20.07.2021 08:42:14 SmileStyle
NotSolved
20.07.2021 22:34:34 Gast62425
NotSolved
21.07.2021 06:42:03 SmileStyle
NotSolved