Microsoft Office Excel ® Kod Kılavuzu

Microsoft Office Excel® Code Guide

1 Ekim 2008 Çarşamba

Workbook Menu




'ThisWorkbook

Option Explicit
Private Sub Workbook_Open()
     On Error Resume Next
     Call Menü_Kur
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
     On Error Resume Next
     Call Menü_Yoket

End Sub

'Module1

Option Explicit
Public Const Sistem_Menü = "Worksheet Menu Bar"
Public Const Program_Menüsü = "PBİD®"
Dim Eleman$
Dim Alt_Eleman$
Sub Menü_Kur()
     On Error Resume Next
     Program_Menüsü_Temizle
Program_Menüsü
     Application.CommandBars.Add Program_Menüsü, , True 'CommandBar / ToolBarMenüsü

     Eleman = "&Bir"
     CommandBars(Program_Menüsü).Controls.Add(Type:=msoControlPopup).Caption = Eleman
     With CommandBars(Program_Menüsü).Controls(Eleman)

          Eleman = "Menü&1"
          .Controls.Add(Type:=msoControlButton).Caption = Eleman
          With .Controls(Eleman)

               .OnAction = "Komut"
               .FaceId = 3
               .State = msoButtonUp
               .Enabled = True
               .BeginGroup = False

          End With
          Eleman = "Menü&2"
          .Controls.Add(Type:=msoControlButton).Caption = Eleman
          With .Controls(Eleman)

               .OnAction = "Komut"
               .State = msoButtonDown
               .Enabled = False
               .BeginGroup = True
               .FaceId = 4

          End With
          Eleman = "Menü&3"
          .Controls.Add(Type:=msoControlEdit).Caption = Eleman
          With .Controls(Eleman)

               .Tag = "TestEditBox"
               .Text = "Yazılı Komutunuz"
               .OnAction = "Komut"

          End With
          Alt_Eleman = "Menü&4"
          .Controls.Add(Type:=msoControlPopup).Caption = Alt_Eleman
          With .Controls(Alt_Eleman)

               Eleman = "Alt Menü&1"
               .Controls.Add(Type:=msoControlButton).Caption = Eleman
               With .Controls(Eleman)

                    .OnAction = "Komut"
               End With
               Eleman = "Alt Menü&2"
               .Controls.Add(Type:=msoControlButton).Caption = Eleman
               With .Controls(Eleman)

                    .OnAction = "Komut"
               End With
               Eleman = "Alt Menü&3"

               .Controls.Add(Type:=msoControlButton).Caption = Eleman
               With .Controls(Eleman)
                    .OnAction = "Komut"
               End With
          End With
          Eleman = "Menü&5"
          .Controls.Add(Type:=msoControlComboBox).Caption = Eleman
          With .Controls(Eleman)

               '.Delete
               .OnAction = "Komut1"
               .Visible = True
               .Enabled = True
               .AddItem "Bir"
               .AddItem "İki"
               .AddItem "Üç"
               .AddItem "Dört"
               .AddItem "Beş"
               .AddItem "Altı"
               .ListIndex = 4
               .DropDownWidth = 36

          End With
          Eleman = "Menü&6"
          .Controls.Add(Type:=msoControlButton).Caption = Eleman
          With .Controls(Eleman)

               .OnAction = "Komut"
               .State = msoButtonDown
               .BeginGroup = True

          End With
     End With
     Eleman = "&İki"
     CommandBars(Program_Menüsü).Controls.Add(msoControlPopup).Caption = Eleman
     With CommandBars(Program_Menüsü).Controls(Eleman)

          Eleman = "Menü&1"
          .Controls.Add(Type:=msoControlButton).Caption = Eleman
          .Controls(Eleman).OnAction = "Komut"
          Eleman = "Menü&1"
          .Controls.Add(Type:=msoControlButton).Caption = Eleman
          With .Controls(Eleman)

               .OnAction = "Komut"
               .BeginGroup = True

          End With
          Eleman = "Menü&1"
          .Controls.Add(Type:=msoControlButton).Caption = Eleman
          With .Controls(Eleman)

               .OnAction = "Komut"
          End With
          Eleman = "Menü&1"
          .Controls.Add(Type:=msoControlButton).Caption = Eleman
          With .Controls(Eleman)

               .OnAction = "Komut"
               .BeginGroup = True

          End With
     End With
     CommandBars(Program_Menüsü).Visible = True

End Sub

'Module2

Option Explicit
Dim Menü_Bar_Elemanı

Sub Kullanılan_Menü()
     On Error Resume Next
     MsgBox CommandBars.ActiveMenuBar.Name

End Sub
Sub Sistem_Menüsü_Düzenle()
     On Error Resume Next
     CommandBars(Sistem_Menü).Visible = True

End Sub
Sub Program_Menüsü_Düzenle()
     On Error Resume Next
     CommandBars(Program_Menüsü).Visible = True

End Sub
Sub Menü_Yoket()
     On Error Resume Next
     Program_Menüsü_Temizle Program_Menüsü

End Sub
Sub Program_Menüsü_Temizle(Menü_Adı)
     On Error Resume Next
     For Each Menü_Bar_Elemanı In CommandBars

          If Menü_Bar_Elemanı.Name = Menü_Adı Then
                Menü_Bar_Elemanı.Delete
          End If
     Next
End Sub
Sub Komut()
     On Error Resume Next
     MsgBox CommandBars.FindControl(Tag:="TestEditBox").Text

End Sub
Sub Komut1()
     On Error Resume Next
     Dim Seçim
     Seçim = CommandBars(Program_Menüsü).Controls("Bir").Controls("Menü5").ListIndex
     Select Case Seçim

          Case 1 :MsgBox "1"
          Case 2 :MsgBox "2"
          Case 3 :MsgBox "3"
          Case 4 :MsgBox "4"
          Case 5 :MsgBox "5"
          Case 6 :MsgBox "6"
     End Select
End Sub

Hiç yorum yok:

Blog Arşivi

Bu gadget'ta bir hata oluştu

Bu Blogda Ara

Contributor

Contributor
Mustafa ULUSARAÇ İstanbul, TÜRKİYE
free counters
T. C. Central Bank Indicative Exchange Rates
Currency Exchange Rate Widget,Currency Converter Widget
Borsa İstanbul