ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What's wrong with this picture?? (https://www.excelbanter.com/excel-programming/333653-whats-wrong-picture.html)

Jody L. Whitlock

What's wrong with this picture??
 
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

bhofsetz[_101_]

What's wrong with this picture??
 

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

?


--
bhofsetz
------------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...o&userid=18807
View this thread: http://www.excelforum.com/showthread...hreadid=384612


Jody L. Whitlock

What's wrong with this picture??
 
bhofsetz wrote:


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


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com