LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 237
Default Saving button on all workbooks

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving Workbooks with a lot of formulas Frans Excel Discussion (Misc queries) 0 April 6th 09 05:27 PM
Saving Workbooks Jamad Excel Discussion (Misc queries) 2 April 10th 08 03:33 PM
Saving the Macro for all workbooks Pranay Shah New Users to Excel 7 July 19th 07 09:11 PM
Saving multiple Workbooks JBC Excel Discussion (Misc queries) 2 July 10th 07 09:28 AM
Saving Workbooks w/ Charts Bob Barnes Excel Discussion (Misc queries) 1 April 22nd 07 04:08 PM


All times are GMT +1. The time now is 07:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"