M
Mary
I have created an AddIn that cointains custom functions and also a
code segment that creates a tool bar that cotains a macro that copies
the VBE module from the xla file to the active workbook.
The problem is that I dont know how to display the toolbar when the
add-in is loaded. In other words, I want the tool bar to be displayed
automatically once I have loaded the add-in. This the code I wrote.
This bugged me the entire day yesterday and I could not figure it out.
Mary
Sub CopyModule()
Dim Name22 As Variant
Dim test as String
Dim EconLibrary As String
Const tBarName As String = "Tool Bar name"
'Delete CommandBar if it exists
On Error Resume Next
CommandBars(tBarName).Delete
On Error GoTo 0
'create CommandBar
CommandBars.Add Name:=tBarName
'define an object variable to refer to the CommandBar
With CommandBars(tBarName)
'add button use 1 to specify a blank custom face
With .Controls.Add(ID:=1)
.OnAction = "Module1.CopyModule"
.Caption = "CopyModule"
.FaceId = 250
End With
'display the toolbar
.Visible = True
End With
Name22 = AddIns("EconLibrary").FullName
With Workbooks("EconLibrary.xla")
test = .Path & "\code.txt"
.VBProject.VBComponents("Module1").Export "test.bas"
End With
ActiveWorkbook.VBProject.VBComponents.Import "test.bas"
End Sub
code segment that creates a tool bar that cotains a macro that copies
the VBE module from the xla file to the active workbook.
The problem is that I dont know how to display the toolbar when the
add-in is loaded. In other words, I want the tool bar to be displayed
automatically once I have loaded the add-in. This the code I wrote.
This bugged me the entire day yesterday and I could not figure it out.
Mary
Sub CopyModule()
Dim Name22 As Variant
Dim test as String
Dim EconLibrary As String
Const tBarName As String = "Tool Bar name"
'Delete CommandBar if it exists
On Error Resume Next
CommandBars(tBarName).Delete
On Error GoTo 0
'create CommandBar
CommandBars.Add Name:=tBarName
'define an object variable to refer to the CommandBar
With CommandBars(tBarName)
'add button use 1 to specify a blank custom face
With .Controls.Add(ID:=1)
.OnAction = "Module1.CopyModule"
.Caption = "CopyModule"
.FaceId = 250
End With
'display the toolbar
.Visible = True
End With
Name22 = AddIns("EconLibrary").FullName
With Workbooks("EconLibrary.xla")
test = .Path & "\code.txt"
.VBProject.VBComponents("Module1").Export "test.bas"
End With
ActiveWorkbook.VBProject.VBComponents.Import "test.bas"
End Sub