Thread: Code Error
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Code Error

typo on that last line

Application.CommandBars("Titles").Controls.OnActio n = _
"DelTitles"

should be

Application.CommandBars("Titles").Controls(2).OnAc tion = _
"DelTitles"

--
Regards,
Tom Ogilvy

"ksn" wrote in message
...
Thanks Tom. I do not do enough programming to remain on top of all of

this.
--
ksn


"Tom Ogilvy" wrote:

Private Sub Workbook_Open()
Application.CommandBars("Titles").Visible = True
Application.CommandBars("Titles").Top = 0
Application.CommandBars("Titles").Left = 0
Application.CommandBars("Titles").Controls(1).OnAc tion = _
"SetTitles"
Application.CommandBars("Titles").Controls.OnActio n = _
"DelTitles"
End Sub

--
Regards,
Tom Ogilvy


"ksn" wrote in message
...
This was old code from Excel 95 and I want to convert this to the

latest.
Basically this macro pulls up a custom toolbar with an assigned macro

to
run
on action.

'
'
'
'
'
' ********************
' Auto_Open Macro
' Opens with File
' ********************
Sub Auto_Open()
Application.Toolbars("Titles").Visible = True
Application.Toolbars("Titles").Top = 0
Application.Toolbars("Titles").Left = 0
Application.Toolbars("Titles").ToolbarButtons(1).O nAction =

"SetTitles"
Application.Toolbars("Titles").ToolbarButtons(2).O nAction =

"DelTitles"
End Sub
'
'
'
'
'
' ********************
' Auto_Close Macro
' Closes with File
' ********************
Sub Auto_Close()
Application.Toolbars("Titles").Visible = False
Application.Toolbars("Fee").Visible = False
Application.Toolbars("Hide_Unhide").Visible = False
End Sub


I tried the following and VBA gives an error on the fourth line

stating
Method or data member not found.

Private Sub Workbook_Open()
Application.CommandBars("Titles").Visible = True
Application.CommandBars("Titles").Top = 0
Application.CommandBars("Titles").Left = 0
Application.CommandBars("Titles").CommandBarButton (1).OnAction =
"SetTitles"
Application.CommandBars("Titles").CommandBarButton (2).OnAction =
"DelTitles"
End Sub
'
'
'
'
' ********************
' Closes Toolbars
'
' ********************
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.Toolbars("Titles").Visible = False
Application.Toolbars("Fee").Visible = False
Application.Toolbars("Hide_Unhide").Visible = False
End Sub




--
ksn