G
GusEvans
Hi-
Problem have a large workbook/macro that the user needs to open occasionaly.
I am trying to create a small sized workbook (ACT-Menu.xls) to open every
time Excel starts, add one menu Item to an existing menu and poit to a local
macro. This macro merely opens the worksheet and starts an Aut
pen
subroutine in the newly opened macro. I have ACT-Menu.xls protected, hidden
and stored in the XLStart Folder. On opening Excel it gives an error on the
following line -
Set cbcNext = Application.CommandBars(1).Controls("ACT!").Controls.Add
Macro code below
If I open the macro in the VB Editor, I can step thru it without error.
What's the problem??
Option Explicit
Private Sub Workbook_Open()
Dim cbcNext As CommandBarControl
Dim strErr As String
Dim intL As Integer
On Error Resume Next
Application.CommandBars(1).Controls("ACT!").Controls("Next Report").Delete
On Error GoTo ErrorHandler
intL = 1
Set cbcNext = Application.CommandBars(1).Controls("ACT!").Controls.Add
intL = 2
cbcNext.Caption = "&Next Report"
intL = 3
cbcNext.OnAction = "OpenACTReports"
intL = 4
cbcNext.BeginGroup = True
intL = 5
Workbooks.Add
Exit Sub
ErrorHandler:
strErr = "Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & Chr(13) & Err.Description & Chr(13) & _
"for line # " & Str(intL)
MsgBox strErr, , "Error", Err.HelpFile, Err.HelpContext
End Sub
Thanks in advance,
Problem have a large workbook/macro that the user needs to open occasionaly.
I am trying to create a small sized workbook (ACT-Menu.xls) to open every
time Excel starts, add one menu Item to an existing menu and poit to a local
macro. This macro merely opens the worksheet and starts an Aut
subroutine in the newly opened macro. I have ACT-Menu.xls protected, hidden
and stored in the XLStart Folder. On opening Excel it gives an error on the
following line -
Set cbcNext = Application.CommandBars(1).Controls("ACT!").Controls.Add
Macro code below
If I open the macro in the VB Editor, I can step thru it without error.
What's the problem??
Option Explicit
Private Sub Workbook_Open()
Dim cbcNext As CommandBarControl
Dim strErr As String
Dim intL As Integer
On Error Resume Next
Application.CommandBars(1).Controls("ACT!").Controls("Next Report").Delete
On Error GoTo ErrorHandler
intL = 1
Set cbcNext = Application.CommandBars(1).Controls("ACT!").Controls.Add
intL = 2
cbcNext.Caption = "&Next Report"
intL = 3
cbcNext.OnAction = "OpenACTReports"
intL = 4
cbcNext.BeginGroup = True
intL = 5
Workbooks.Add
Exit Sub
ErrorHandler:
strErr = "Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & Chr(13) & Err.Description & Chr(13) & _
"for line # " & Str(intL)
MsgBox strErr, , "Error", Err.HelpFile, Err.HelpContext
End Sub
Thanks in advance,