ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code Error (https://www.excelbanter.com/excel-programming/348668-code-error.html)

ksn

Code Error
 
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

Tom Ogilvy

Code Error
 
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




ksn

Code Error
 
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





Tom Ogilvy

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








All times are GMT +1. The time now is 05:24 PM.

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