Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The below code creates a button on the Worksheet Menu Bar
at the top and assigns the macro ImporrtData to it. The problem is when I save the workbook and then reopen it, the button is no longer there, nor is it there on any other workbook I open. Is there a way I can save it there permanently? Sub testaddbutton() Dim newMenu As CommandBarPopup Dim ctrlPopUp As CommandBarControl Dim ctrlButton As CommandBarControl Dim nButtonPos Dim nButtons Dim lpszButtonName$ If MsgBox("Are you sure?", vbYesNo) = vbNo Then Exit Sub Else End If nButtonPos = 0 nButtons = Application.CommandBars.ActiveMenuBar.Controls.Cou nt ' see if the button is already placed If nButtons = 0 Then For i = 1 To nButtons lpszButtonName$ = Application.CommandBars.ActiveMenuBar.Controls(i). Caption If lpszButtonName$ = "Import Data" Then Exit Sub Next End If Set newMenu = CommandBars("Worksheet Menu Bar").Controls.Add(Type:=msoControlPopup, Temporary:=True) newMenu.Caption = "Import Data" Set ctrlPopUp = newMenu.Controls.Add (Type:=msoControlPopup, ID:=1) ctrlPopUp.Caption = "Please Select..." Set ctrlButton = ctrlPopUp.Controls.Add (Type:=msoControlButton, ID:=1) ctrlButton.Caption = "Import Data..." ctrlButton.Style = msoButtonCaption ctrlButton.OnAction = "ImporrtData" ' This will add the Button Import Data to the Menu Bar ' Under this button will be a button called "Import Data..." ' this button will run the macro called ImporrtData End Sub Thanks Todd Huttenstine |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Saving Workbooks with a lot of formulas | Excel Discussion (Misc queries) | |||
Saving Workbooks | Excel Discussion (Misc queries) | |||
Saving the Macro for all workbooks | New Users to Excel | |||
Saving multiple Workbooks | Excel Discussion (Misc queries) | |||
Saving Workbooks w/ Charts | Excel Discussion (Misc queries) |