PC Review


Reply
Thread Tools Rate Thread

command bar name not recognized

 
 
salgud
Guest
Posts: n/a
 
      9th Jan 2009
I've cobbled together the following code to create a toolbar everytime a
certain spreadsheet opens:

Sub CreateOSIMenubar()

Dim vMacNames As Variant
Dim vCapNames As Variant
Dim vTipText As Variant

Call RemoveOSIMenubar

vMacNames = "OSILogInsertRow"
vCapNames = "OSILogInsertRow"
vTipText = "Add Row"

With Application.CommandBars
.Add
.Name = vMacNames <----- Compile Error: Method or Data Member not found
.Left = 200
.Top = 200
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarTop
.Left = CommandBars("FormatDGB").Left + CommandBars("FormatDGB").Width
.RowIndex = CommandBars("FormatDGB").RowIndex
End With
With CommandBars(vMacNames).Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & vMacNames
.Caption = vCapNames
.Style = msoButtonCaption
.TooltipText = vTipText
End With
End Sub

Doesn't recognize the name variable or something. Any ideas?
Thanks
 
Reply With Quote
 
 
 
 
Gord Dibben
Guest
Posts: n/a
 
      9th Jan 2009
With Application.CommandBars.Add
.Name = vMacNames
'rest of stuff


Gord Dibben MS Excel MVP

On Fri, 9 Jan 2009 16:32:43 -0700, salgud <(E-Mail Removed)> wrote:

>I've cobbled together the following code to create a toolbar everytime a
>certain spreadsheet opens:
>
>Sub CreateOSIMenubar()
>
>Dim vMacNames As Variant
>Dim vCapNames As Variant
>Dim vTipText As Variant
>
>Call RemoveOSIMenubar
>
>vMacNames = "OSILogInsertRow"
>vCapNames = "OSILogInsertRow"
>vTipText = "Add Row"
>
>With Application.CommandBars
> .Add
> .Name = vMacNames <----- Compile Error: Method or Data Member not found
> .Left = 200
> .Top = 200
> .Protection = msoBarNoProtection
> .Visible = True
> .Position = msoBarTop
> .Left = CommandBars("FormatDGB").Left + CommandBars("FormatDGB").Width
> .RowIndex = CommandBars("FormatDGB").RowIndex
>End With
>With CommandBars(vMacNames).Controls.Add(Type:=msoControlButton)
> .OnAction = "'" & ThisWorkbook.Name & "'!" & vMacNames
> .Caption = vCapNames
> .Style = msoButtonCaption
> .TooltipText = vTipText
>End With
>End Sub
>
>Doesn't recognize the name variable or something. Any ideas?
>Thanks


 
Reply With Quote
 
salgud
Guest
Posts: n/a
 
      12th Jan 2009
On Fri, 09 Jan 2009 15:50:59 -0800, Gord Dibben wrote:

> With Application.CommandBars.Add
> .Name = vMacNames
> 'rest of stuff
>

Thanks for the reply, Gord. When I try that, I get a "Invalid or
unqualified reference" error on that same lime. Any ideas?

>
> Gord Dibben MS Excel MVP
>
> On Fri, 9 Jan 2009 16:32:43 -0700, salgud <(E-Mail Removed)> wrote:
>
>>I've cobbled together the following code to create a toolbar everytime a
>>certain spreadsheet opens:
>>
>>Sub CreateOSIMenubar()
>>
>>Dim vMacNames As Variant
>>Dim vCapNames As Variant
>>Dim vTipText As Variant
>>
>>Call RemoveOSIMenubar
>>
>>vMacNames = "OSILogInsertRow"
>>vCapNames = "OSILogInsertRow"
>>vTipText = "Add Row"
>>
>>With Application.CommandBars
>> .Add
>> .Name = vMacNames <----- Compile Error: Method or Data Member not found
>> .Left = 200
>> .Top = 200
>> .Protection = msoBarNoProtection
>> .Visible = True
>> .Position = msoBarTop
>> .Left = CommandBars("FormatDGB").Left + CommandBars("FormatDGB").Width
>> .RowIndex = CommandBars("FormatDGB").RowIndex
>>End With
>>With CommandBars(vMacNames).Controls.Add(Type:=msoControlButton)
>> .OnAction = "'" & ThisWorkbook.Name & "'!" & vMacNames
>> .Caption = vCapNames
>> .Style = msoButtonCaption
>> .TooltipText = vTipText
>>End With
>>End Sub
>>
>>Doesn't recognize the name variable or something. Any ideas?
>>Thanks

 
Reply With Quote
 
salgud
Guest
Posts: n/a
 
      12th Jan 2009
On Mon, 12 Jan 2009 11:38:42 -0700, salgud wrote:

> On Fri, 09 Jan 2009 15:50:59 -0800, Gord Dibben wrote:
>
>> With Application.CommandBars.Add
>> .Name = vMacNames
>> 'rest of stuff
>>

> Thanks for the reply, Gord. When I try that, I get a "Invalid or
> unqualified reference" error on that same lime. Any ideas?


My mistake, error message is "Invalid procedure call or reference"

>
>>
>> Gord Dibben MS Excel MVP
>>
>> On Fri, 9 Jan 2009 16:32:43 -0700, salgud <(E-Mail Removed)> wrote:
>>
>>>I've cobbled together the following code to create a toolbar everytime a
>>>certain spreadsheet opens:
>>>
>>>Sub CreateOSIMenubar()
>>>
>>>Dim vMacNames As Variant
>>>Dim vCapNames As Variant
>>>Dim vTipText As Variant
>>>
>>>Call RemoveOSIMenubar
>>>
>>>vMacNames = "OSILogInsertRow"
>>>vCapNames = "OSILogInsertRow"
>>>vTipText = "Add Row"
>>>
>>>With Application.CommandBars
>>> .Add
>>> .Name = vMacNames <----- Compile Error: Method or Data Member not found
>>> .Left = 200
>>> .Top = 200
>>> .Protection = msoBarNoProtection
>>> .Visible = True
>>> .Position = msoBarTop
>>> .Left = CommandBars("FormatDGB").Left + CommandBars("FormatDGB").Width
>>> .RowIndex = CommandBars("FormatDGB").RowIndex
>>>End With
>>>With CommandBars(vMacNames).Controls.Add(Type:=msoControlButton)
>>> .OnAction = "'" & ThisWorkbook.Name & "'!" & vMacNames
>>> .Caption = vCapNames
>>> .Style = msoButtonCaption
>>> .TooltipText = vTipText
>>>End With
>>>End Sub
>>>
>>>Doesn't recognize the name variable or something. Any ideas?
>>>Thanks

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      12th Jan 2009
Can you post the removeosimenubar code?

That is probably throwing an error when you try to remove a bar that does
not yet exist.

With my limited skills I don't see what these two lines do.

..Left = CommandBars("FormatDGB").Left + CommandBars("FormatDGB").Width
.RowIndex = CommandBars("FormatDGB").RowIndex

Maybe you have to wrap them inside their own With...........End With


Gord

On Mon, 12 Jan 2009 12:00:31 -0700, salgud <(E-Mail Removed)> wrote:

>On Mon, 12 Jan 2009 11:38:42 -0700, salgud wrote:
>
>> On Fri, 09 Jan 2009 15:50:59 -0800, Gord Dibben wrote:
>>
>>> With Application.CommandBars.Add
>>> .Name = vMacNames
>>> 'rest of stuff
>>>

>> Thanks for the reply, Gord. When I try that, I get a "Invalid or
>> unqualified reference" error on that same lime. Any ideas?

>
>My mistake, error message is "Invalid procedure call or reference"
>
>>
>>>
>>> Gord Dibben MS Excel MVP
>>>
>>> On Fri, 9 Jan 2009 16:32:43 -0700, salgud <(E-Mail Removed)> wrote:
>>>
>>>>I've cobbled together the following code to create a toolbar everytime a
>>>>certain spreadsheet opens:
>>>>
>>>>Sub CreateOSIMenubar()
>>>>
>>>>Dim vMacNames As Variant
>>>>Dim vCapNames As Variant
>>>>Dim vTipText As Variant
>>>>
>>>>Call RemoveOSIMenubar
>>>>
>>>>vMacNames = "OSILogInsertRow"
>>>>vCapNames = "OSILogInsertRow"
>>>>vTipText = "Add Row"
>>>>
>>>>With Application.CommandBars
>>>> .Add
>>>> .Name = vMacNames <----- Compile Error: Method or Data Member not found
>>>> .Left = 200
>>>> .Top = 200
>>>> .Protection = msoBarNoProtection
>>>> .Visible = True
>>>> .Position = msoBarTop
>>>> .Left = CommandBars("FormatDGB").Left + CommandBars("FormatDGB").Width
>>>> .RowIndex = CommandBars("FormatDGB").RowIndex
>>>>End With
>>>>With CommandBars(vMacNames).Controls.Add(Type:=msoControlButton)
>>>> .OnAction = "'" & ThisWorkbook.Name & "'!" & vMacNames
>>>> .Caption = vCapNames
>>>> .Style = msoButtonCaption
>>>> .TooltipText = vTipText
>>>>End With
>>>>End Sub
>>>>
>>>>Doesn't recognize the name variable or something. Any ideas?
>>>>Thanks


 
Reply With Quote
 
salgud
Guest
Posts: n/a
 
      12th Jan 2009
On Mon, 12 Jan 2009 13:46:44 -0800, Gord Dibben wrote:

> Can you post the removeosimenubar code?
>
> That is probably throwing an error when you try to remove a bar that does
> not yet exist.
>

That fixed it! Thanks, Gord.

> With my limited skills I don't see what these two lines do.
>
> .Left = CommandBars("FormatDGB").Left + CommandBars("FormatDGB").Width
> .RowIndex = CommandBars("FormatDGB").RowIndex


> Maybe you have to wrap them inside their own With...........End With
>
>
> Gord
>
> On Mon, 12 Jan 2009 12:00:31 -0700, salgud <(E-Mail Removed)> wrote:
>
>>On Mon, 12 Jan 2009 11:38:42 -0700, salgud wrote:
>>
>>> On Fri, 09 Jan 2009 15:50:59 -0800, Gord Dibben wrote:
>>>
>>>> With Application.CommandBars.Add
>>>> .Name = vMacNames
>>>> 'rest of stuff
>>>>
>>> Thanks for the reply, Gord. When I try that, I get a "Invalid or
>>> unqualified reference" error on that same lime. Any ideas?

>>
>>My mistake, error message is "Invalid procedure call or reference"
>>
>>>
>>>>
>>>> Gord Dibben MS Excel MVP
>>>>
>>>> On Fri, 9 Jan 2009 16:32:43 -0700, salgud <(E-Mail Removed)> wrote:
>>>>
>>>>>I've cobbled together the following code to create a toolbar everytime a
>>>>>certain spreadsheet opens:
>>>>>
>>>>>Sub CreateOSIMenubar()
>>>>>
>>>>>Dim vMacNames As Variant
>>>>>Dim vCapNames As Variant
>>>>>Dim vTipText As Variant
>>>>>
>>>>>Call RemoveOSIMenubar
>>>>>
>>>>>vMacNames = "OSILogInsertRow"
>>>>>vCapNames = "OSILogInsertRow"
>>>>>vTipText = "Add Row"
>>>>>
>>>>>With Application.CommandBars
>>>>> .Add
>>>>> .Name = vMacNames <----- Compile Error: Method or Data Member not found
>>>>> .Left = 200
>>>>> .Top = 200
>>>>> .Protection = msoBarNoProtection
>>>>> .Visible = True
>>>>> .Position = msoBarTop
>>>>> .Left = CommandBars("FormatDGB").Left + CommandBars("FormatDGB").Width
>>>>> .RowIndex = CommandBars("FormatDGB").RowIndex
>>>>>End With
>>>>>With CommandBars(vMacNames).Controls.Add(Type:=msoControlButton)
>>>>> .OnAction = "'" & ThisWorkbook.Name & "'!" & vMacNames
>>>>> .Caption = vCapNames
>>>>> .Style = msoButtonCaption
>>>>> .TooltipText = vTipText
>>>>>End With
>>>>>End Sub
>>>>>
>>>>>Doesn't recognize the name variable or something. Any ideas?
>>>>>Thanks

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
500 Command not recognized =?Utf-8?B?Um9nZXI=?= Microsoft Outlook Discussion 1 15th Dec 2005 06:33 PM
Getting not recognized command when I type in any command . =?Utf-8?B?TW9r?= Microsoft Windows 2000 CMD Promt 6 9th Jan 2005 12:27 AM
Net command is not recognized Ales Baranek Microsoft Windows 2000 3 22nd Oct 2004 07:24 PM
DOS command not recognized in XP Lou Windows XP General 3 4th Jul 2004 12:08 PM
Re: 'NET' is not recognized as a command Bill Stewart Microsoft Windows 2000 CMD Promt 0 1st Jul 2003 07:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:44 PM.