D
DavidP
I have the following code which should create a command bar and add 17
buttons. I shortened the example to 3 buttons to save readers time.
Sub Workbook_Open()
'Delete CommandBar if it exists
On Error Resume Next
CommandBars("DataEntry").Delete
On Error GoTo 0
CommandBars.Add Name:="DataEntry"
With
Application.CommandBars("DataEntry").Controls.Add(temporary:=True)
.Caption = "Anti Virus"
.OnAction = "PasteAntiVirus"
End With
With
Application.CommandBars("DataEntry").Controls.Add(temporary:=True)
.Caption = "Audio"
.OnAction = "PasteAudio"
End With
With
Application.CommandBars("DataEntry").Controls.Add(temporary:=True)
.Caption = "Backup"
.OnAction = "PasteBackup"
End With
End Sub
When I open the spreadsheet the macro stops at the line
CommandBars.Add Name:="DataEntry"
The error message is "Run Time error '91' Object Variable ot With
Block Variable not set
I have looked through previous postings but none seem relevant to my
problem. The macro runs when I open the spreadsheet. My XL version
is 2000 running on Win98.
Can anyone point me in the right direction please
David P
buttons. I shortened the example to 3 buttons to save readers time.
Sub Workbook_Open()
'Delete CommandBar if it exists
On Error Resume Next
CommandBars("DataEntry").Delete
On Error GoTo 0
CommandBars.Add Name:="DataEntry"
With
Application.CommandBars("DataEntry").Controls.Add(temporary:=True)
.Caption = "Anti Virus"
.OnAction = "PasteAntiVirus"
End With
With
Application.CommandBars("DataEntry").Controls.Add(temporary:=True)
.Caption = "Audio"
.OnAction = "PasteAudio"
End With
With
Application.CommandBars("DataEntry").Controls.Add(temporary:=True)
.Caption = "Backup"
.OnAction = "PasteBackup"
End With
End Sub
When I open the spreadsheet the macro stops at the line
CommandBars.Add Name:="DataEntry"
The error message is "Run Time error '91' Object Variable ot With
Block Variable not set
I have looked through previous postings but none seem relevant to my
problem. The macro runs when I open the spreadsheet. My XL version
is 2000 running on Win98.
Can anyone point me in the right direction please
David P