Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run Macro when loading addin
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run Macro when loading addin
|
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run Macro when loading addin
You could call your macros from the auto_open() routine or from the
workbook_open() event: In a general module: sub auto_open() call copyModule end sub Under the ThisWorkbook module: Private Sub Workbook_Open() call CopyModule end sub Use one or the other--not both. Mary wrote: 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 -- Dave Peterson |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run Macro when loading addin
Thanks a lot , problem solved. Mary *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Addins-Slow loading of each individual Addin using Excel 2007 | Excel Discussion (Misc queries) | |||
Analysis Tool Pack addin into Excel and it is not loading | Excel Discussion (Misc queries) | |||
Dynamically Loading Macro with data | Charts and Charting in Excel | |||
addin loading issue | Excel Discussion (Misc queries) | |||
Changing the Name of an Addin and loading worksheets off a network drive | Excel Programming |