/build/static/layout/Breadcrumb_cap_w.png

Create a button in Excell with vbs

'=====================================================================================================

' WAT DOET DIT SCRIPT: Voorbeeld script om een werkbalk met knop in Excel toe te voegen.

'------------------------------------------------------------------------------------------------------

' HOE DIT SCRIPT TE GEBRUIKEN:

' 1. INPUT: N.V.T

' 2. OUTPUT: Button in Excel

' 3. PARAMETRS: N.V.T

'-----------------------------------------------------------------------------------------------------

' NAAM: A_InstallButton.VBS

' AUTEUR: Roberto Pibia

' VERSIE TEMPLATE: 1.0

' COMMENTAAR 26-02-2010,

' VERSIE TEMPLATE: x.x

' COMMENTAAR , :

'

'=====================================================================================================

'On Error Resume Next

Const cmdBarName = "wbDIS"

Const cmdBarStyleStandard = 0

Const cmdBarStyleIconOnly = 1

Const cmdBarStyleCaptionOnly = 2

Const cmdBarStyleIconAndCaption = 3

Const cmdBarPositionLeft = 0

Const cmdBarPositionTop = 1

Const cmdBarPositionRight = 2

Const cmdBarPositionBottom = 3

Const cmdBarPositionFLoating = 4

Const cmdBarProtectionOff = 0

Const cmdBarProtectionOn = 1

Const cmdBarIconNr = 39

Dim oXL

Dim oAddin

Set oXL = CreateObject("Excel.Application")

createMenuBar

'Sub to install the button

'---------------------------------------------------

Sub createMenuBar()

Dim wbDIS, bExists

bExists = False

For Each bar In oXL.CommandBars

If bar.Name = cmdBarName Then

bExists = True

End If

Next

If bExists = False Then

oXL.CommandBars.Add(cmdBarName)

'oXL.CommandBars(cmdBarName).Name = "Roberto"

oXL.CommandBars(cmdBarName).Position = cmdBarPositionTop

oXL.CommandBars(cmdBarName).Visible = True

oXL.CommandBars(cmdBarName).Protection = cmdBarProtectionOff

End If

Set wbDIS = oXL.CommandBars.Item(cmdBarName)

If wbDIS.Controls.Count = 0 Then

wbDIS.Controls.Add

wbDIS.Controls(1).DescriptionText = "Opslaan in DIS"

wbDIS.Controls(1).OnAction = "OpslaanIn..."

wbDIS.Controls(1).Caption = "Opslaan in ..."

wbDIS.Controls(1).Style = cmdBarStyleIconAndCaption

wbDIS.Controls(1).FaceId = cmdBarIconNr

wbDIS.Controls.Add

wbDIS.Controls(2).DescriptionText = "Openen in ..."

wbDIS.Controls(2).OnAction = "OpenenInDis"

wbDIS.Controls(2).Caption = "Openen in ..."

wbDIS.Controls(2).Style = cmdBarStyleIconAndCaption

wbDIS.Controls(2).FaceId = cmdBarIconNr

End If

Set wbDIS = Nothing

End Sub

oXL.Quit

Set oXL = Nothing


Comments

This post is locked
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ