What's wrong with this picture??

  • Thread starter Jody L. Whitlock
  • Start date
J

Jody L. Whitlock

Maybe I'm missing something, but this should be working...

Private WithEvents objCommandBarButton As CommandBarButton

Private Sub Workbook_Open()
Dim obkCommandbars As CommandBars
Dim objCommandBar As CommandBar
Dim objCommandBarControl As CommandBarControl

' Create a menu command on the "Tools" menu.
objCommandBars = Me.Application.CommandBars("Tools")
objCommandBar = objCommandBars.Item("Tools")

' Make sure menu command doesn't already exist.
For Each objCommandBarControl In objCommandBar.Controls
If objCommandBarControl.Caption = "Perform Metric conversion..."
Then
objCommandBar.Controls.Item("Perform Metric
conversion...").Delete
End If
Next objCommandBarControl

objCommandBarButton = objCommandBar.Controls.Add(msoControlButton)

With objCommandBarButton
.Caption = "Perform Metrics Conversion..."
.Style = msoButtonCaption
.Tag = "Perform Metrics Conversion..."
.OnAction = "!<Magic_Metrics.Connect>"
.Visible = True
End With
End Sub

Thanks,
Jody W
 
B

bhofsetz

Jody,
What error is this code giving you?

at first glance It looks like you have a typo in your Dim statement

Dim obkCommandbars As CommandBars

should this read

Dim objCommandbars As CommandBars

?
 
J

Jody L. Whitlock

bhofsetz said:
Jody,
What error is this code giving you?

at first glance It looks like you have a typo in your Dim statement

Dim obkCommandbars As CommandBars

should this read

Dim objCommandbars As CommandBars

?

Sorry for the double-post, first time using this newsreader. The main
thread is under "Am I missing something???"
The error I'm recieving is this:

he error I'm getting is 'Object Required' on this line:

' Create a menu command on the "Tools" menu.
Set objCommandbars = applicationObject.CommandBars

I haven't done VBA/VB6 in a while since I have moved onto .NET.


Thanks,
Jody
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top