Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Creating toolbar macro errors

Hello. Below is some Dave Peterson code that I found (and modified). I simply
want to create a floating toolbar with one button for my macro. However,
whenever I start Excel or uninstall/install this add-in, it errors out on
naming the commandbar. I get "Invalid procedure call or argument". It seems
to be naming the commandbar "Custom 1", and then it won't rename it. I'm
puzzled. thanks.

'===========================================
Sub Auto_Open()
Call CreateMenubar
End Sub

'===========================================
Sub Auto_Close()
Call RemoveMenubar
End Sub

'===========================================
Sub RemoveMenubar()
On Error Resume Next
Application.CommandBars("View").Delete
On Error GoTo 0
End Sub

'===========================================
Sub CreateMenubar()

Call RemoveMenubar

With Application.CommandBars.Add
.Name = "View" '<<<<<<<<<Errors here
.Left = 200
.Top = 200
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarFloating

With .Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "Unhide_All_WS"
.Caption = "Unhide All Sheets"
.Style = msoButtonIconAndCaption
.FaceId = 229
End With

End With
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Creating toolbar macro errors

You need to choose a name that's not already being used by another
commandbar.

In article ,
Jason Morin wrote:

Hello. Below is some Dave Peterson code that I found (and modified). I simply
want to create a floating toolbar with one button for my macro. However,
whenever I start Excel or uninstall/install this add-in, it errors out on
naming the commandbar. I get "Invalid procedure call or argument". It seems
to be naming the commandbar "Custom 1", and then it won't rename it. I'm
puzzled. thanks.

'===========================================
Sub Auto_Open()
Call CreateMenubar
End Sub

'===========================================
Sub Auto_Close()
Call RemoveMenubar
End Sub

'===========================================
Sub RemoveMenubar()
On Error Resume Next
Application.CommandBars("View").Delete
On Error GoTo 0
End Sub

'===========================================
Sub CreateMenubar()

Call RemoveMenubar

With Application.CommandBars.Add
.Name = "View" '<<<<<<<<<Errors here
.Left = 200
.Top = 200
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarFloating

With .Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "Unhide_All_WS"
.Caption = "Unhide All Sheets"
.Style = msoButtonIconAndCaption
.FaceId = 229
End With

End With
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Creating toolbar macro errors

Oops - should have been commandbar or menu bar popup.

In article ,
JE McGimpsey wrote:

You need to choose a name that's not already being used by another
commandbar.

Reply
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
Creating ranges in closed workbooks without #REF errors Conor Excel Discussion (Misc queries) 0 June 26th 07 04:22 PM
Creating macro button on toolbar tanyhart[_33_] Excel Programming 1 July 13th 06 03:10 PM
Creating a macro that simulates some of the toolbar button Duangruthai New Users to Excel 1 April 22nd 06 12:12 AM
Sort creating total errors excel idiot Excel Discussion (Misc queries) 7 January 16th 05 03:21 PM
Creating a Toolbar with a macro DavidP[_3_] Excel Programming 7 December 5th 03 10:22 AM


All times are GMT +1. The time now is 10:31 PM.

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

About Us

"It's about Microsoft Excel"