run-time error '424'

  • Thread starter Elias Hämäläinen
  • Start date
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
 
J

JackD

The code below seems to just be setting the toolbar. It doesn't handle what
the toolbar does.
Looks like when you click a button it should execute SimpleProjectInfo.Show.
What does that do? I'd look at it for your problem
 
E

Elias Hämäläinen

SimpleProjectInfo is a simple form what I made. It doesn't contain any code.
I have been thinking that somehow it doesn't find the form. But what's
causing this? When I put the form and the code under
VBAProject(myproject.Published) the button works fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top