Attribute VB_Name = "Module1" Sub LueSiirtoTiedosto() MsgBox "Luku valmis" End Sub Sub TallennaSiirtoTiedosto() MsgBox "Tallennus valmis" End Sub Public Function PalkkiOlemassa(ByVal PNimi As String) As Boolean Dim NoOfBars As Long Dim Lp As Long Dim TmpB As Boolean TmpB = False NoOfBars = Application.CommandBars.Count For Lp = 1 To NoOfBars If Application.CommandBars(Lp).Name = PNimi Then TmpB = True End If Next Lp PalkkiOlemassa = TmpB End Function Sub TestaaPalkkiOlemassa() MsgBox PalkkiOlemassa("Standard") End Sub Public Sub Piiloon_StaFor() Application.CommandBars("Standard").Visible = False Application.CommandBars("Formatting").Visible = False End Sub Public Sub Nakyville_StaFor() Application.CommandBars("Standard").Visible = True Application.CommandBars("Formatting").Visible = True End Sub Public Sub PiilotaOmaPainikePalkki() If PalkkiOlemassa("Makronapit") Then Application.CommandBars("Makronapit").Visible = False End If End Sub Public Sub NaytaOmaPainikePalkki() If PalkkiOlemassa("Makronapit") Then Application.CommandBars("Makronapit").Visible = True End If End Sub Public Sub OmatPainikkeet() If Not PalkkiOlemassa("Makronapit") Then Application.CommandBars.Add "Makronapit", , , True With Application.CommandBars("Makronapit") .Controls.Add msoControlButton .Controls.Add msoControlButton .Controls(1).Style = msoButtonIconAndCaption .Controls(2).Style = msoButtonIconAndCaption .Controls(1).FaceId = 39 .Controls(2).FaceId = 141 .Controls(1).Caption = "Lue Siirto" .Controls(2).Caption = "Vie Siirto" .Controls(1).OnAction = "LueSiirtoTiedosto" .Controls(2).OnAction = "TallennaSiirtoTiedosto" .Controls(1).TooltipText = "Siirtotiedoston luku" .Controls(2).TooltipText = "Siirtotiedoston tallennus" End With End If Call NaytaOmaPainikePalkki End Sub Public Sub PoistaOmatPainikkeet() If PalkkiOlemassa("Makronapit") Then Application.CommandBars("Makronapit").Delete End If End Sub Public Sub LisaaToolsSub001() Dim SovMenu As CommandBarControl Set SovMenu = CommandBars("Tools").Controls.Add(Type:=msoControlButton, Temporary:=True) SovMenu.Caption = "Lue siirtotiedosto" SovMenu.BeginGroup = True SovMenu.OnAction = "LueSiirtoTiedosto" End Sub Public Sub PoistaToolsSub001() Dim Lp As Long On Error GoTo Loppu For Lp = 1 To Application.CommandBars("Tools").Controls.Count If CommandBars("Tools").Controls(Lp).Caption = "Lue siirtotiedosto" Then CommandBars("Tools").Controls(Lp).Delete End If Next Lp Loppu: End Sub