Error 424 runtime, object required

G

Gaby

Hello everybody:
I´m developing some macros in project professional 2003 for a specific
requirement. I need that custom durations enterprise date 1 and enterprise
date 2 draw in gantt chart like task bars. So I was developing this macros.
On my developer environment all works fine, but when I test in production
environment I get some errors. In many PC´s when I open Project Professional
2003 and this load Enterprise Global Template, appears an error runtime 424:
object required in this line (***): Set y.proj=Application.ActiveProject. The
error says that a Project object is required:

Option Explicit
Dim Y as NEW EventClassModule
Sub Initialize_App()
Set y.app=MSProject.Application
(***) Set y.proj= Application.ActiveProject
End sub
This code is in a module names MyModule in Enterprise Global Template

I don´t understand why this error appears in some PC´s and in another PC´s
doesn´t appear. In a forum I read that maybe the error is that I declare
variable Y like Dim, so I change this line by:
Public Y As New EventClassModule
but the error still appears when I open Project Professional 2003 with a
Windows Account.
In EventClassModule class module I write this code:

Option Explicit
Option Base 1
Public With Events App As Application
Public With Events Proj As Project

Private Sub App_ProjectBeforeTaskChange(Byval tsk As MSProject.Task, Byval
Field As PjField, ByVal NewVal as Variant, Cancel As Boolean)
If (Field= PjTaskEnterpriseDate1) Or (Field=PjTaskEnterpriseDate2)
tsk.EnterpriseFlag2=1
End If


Private Sub App_ProjectTaskNew(Byva pj As Project , ByVal ID As Long)
For each tarea in ActiveSelection.Tasks
tarea.EnterpriseNumber5= 0
tarea.EnterpriseNumber6= 0
Next tarea

In ThisProject in Enterprise Global Template I write this code

Private Sub Project Open(Byval Pj as Project)
Call Initialize_App
End Sub


I have another module in Enterprise Global Template, that copy
EnterpriseDate1 to Start1 and EnterpriseDate2 to Finish 1, and this code is
active whit a buttom in a toolbar.

Could you help me, please? Why appears this error in some PC´s. I´m
desperate about this error. I´m new in developing macros and maybe I´m not
doing a good procedure. Could you help me????
Please, Help me!!!
Thanks in advance.
Gaby.
 
R

Rod Gill

Do the PCs where the error appears have macro security set to medium or low?
What version of Project?
On the PCs that display the error, can you open the VBE and check the
references (tools, references in the VBE). DO any of the checked references
have error? You may need to select each checked reference to check by
looking at the bottom of the dialog.
--

Rod Gill
Project MVP

NEW!! Project VBA Book, for details visit: http://www.projectvbabook.com
 
G

Gaby

On PC´s where the error appears, the version is Project Professional 2003 and
have macro securit set to low. Please, could you explain me more about
references? What references I need check it?
 
R

Rod Gill

Default references are fine, but if there has been an installation problem,
some of the libraries referenced may not be there which would cause
compilation problems which could explain what you are seeing. Do any of your
references have Missing against them?

--

Rod Gill
Project MVP

NEW!! Project VBA Book, for details visit: http://www.projectvbabook.com
 
G

Gaby

I have reinstalled project professional 2003 in a PC with a error appears,
and on this PC in Visual Basic Editor in Project Professionals, in References
are checked this items:
Visual Basic For Application
Microsoft Project 11.0 Object Library
OLE Automation
Microsoft Office 11.0 Object Library
Microsoft Forms 2.0 Object Library

and the error still appears.
How can i detect what references are missing ?
I forgot to tell you that i declare two class modules, maybe is there a
cause of my problem?
Please, help me.
Thanks in advance.
 
R

Rod Gill

References aren't missing, but the files they point to maybe. Are all PCs on
Office 2003 or are some still on Office 2002 or earlier?

Click on each reference and look at the information at the bottom of the
dialog (on a PC that shows errors).

Click Debug, Compile and does an error appear? If so, what?

--

Rod Gill
Project MVP

NEW!! Project VBA Book, for details visit: http://www.projectvbabook.com
 

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