E
Elias Hämäläinen
Hi,
I'm using following code to create new menu item in project which is
supposed to show my form. The new menu item shows up just fine, but when I
click it I get this error:
"run-time error '424' Object required"
The code and the form is stored in ProjectGlobal (Global.MPT). Can't
understand what I'm doing wrong. Any ideas? Thanks.
Private Sub Project_Open(ByVal pj As Project)
Dim objViewBar As CommandBar
Dim objNewItem As CommandBarButton
Dim intTotalItems As Integer
Set objViewBar = Application.CommandBars("Project")
intTotalItems = objViewBar.Controls.Count
If objViewBar.Controls(intTotalItems).Caption <> "Simple Project Info"
Then
Set objNewItem = objViewBar.Controls.Add(Type:=msoControlButton)
objNewItem.Caption = "Simple Project Info"
objNewItem.BeginGroup = True
objNewItem.OnAction = "SimpleProjectInfo.Show"
End If
Set objNewItem = Nothing
Set objViewBar = Nothing
End Sub
Private Sub Project_BeforeClose(ByVal pj As Project)
Dim objViewBar As CommandBar
Dim intTotalItems As Integer
Application.StatusBar = False
Set objViewBar = Application.CommandBars("Project")
intTotalItems = objViewBar.Controls.Count
If objViewBar.Controls(intTotalItems).Caption = "Simple Project Info" Then
objViewBar.Controls(intTotalItems).Delete
End If
Set objViewBar = Nothing
End Sub
I'm using following code to create new menu item in project which is
supposed to show my form. The new menu item shows up just fine, but when I
click it I get this error:
"run-time error '424' Object required"
The code and the form is stored in ProjectGlobal (Global.MPT). Can't
understand what I'm doing wrong. Any ideas? Thanks.
Private Sub Project_Open(ByVal pj As Project)
Dim objViewBar As CommandBar
Dim objNewItem As CommandBarButton
Dim intTotalItems As Integer
Set objViewBar = Application.CommandBars("Project")
intTotalItems = objViewBar.Controls.Count
If objViewBar.Controls(intTotalItems).Caption <> "Simple Project Info"
Then
Set objNewItem = objViewBar.Controls.Add(Type:=msoControlButton)
objNewItem.Caption = "Simple Project Info"
objNewItem.BeginGroup = True
objNewItem.OnAction = "SimpleProjectInfo.Show"
End If
Set objNewItem = Nothing
Set objViewBar = Nothing
End Sub
Private Sub Project_BeforeClose(ByVal pj As Project)
Dim objViewBar As CommandBar
Dim intTotalItems As Integer
Application.StatusBar = False
Set objViewBar = Application.CommandBars("Project")
intTotalItems = objViewBar.Controls.Count
If objViewBar.Controls(intTotalItems).Caption = "Simple Project Info" Then
objViewBar.Controls(intTotalItems).Delete
End If
Set objViewBar = Nothing
End Sub