Error 1004 when saving

A

angus404

I am using Project 2007 and have some VBA code in the Project_BeforeSave
event. This code worked fine in Project 2003, and it works fine when the user
clicks on the save button.

However, if the user closes the project and chooses "Save" and "Check In" I
get an error 1004. The error occurs when trying to get
ActiveProject.CurrentView. When debugging, I get the same error if I try to
access any properties of the ActiveProject.

How can I access the ActiveProject in the BeforeSave event if it doesn't
exist?
 
R

Rod Gill

Hi,

The Before_Save event is passed a pj parameter representing the project that
is saving. In all cases you should use pj instead of ActiveProject if it's
provided. I think this will resolve your issue.

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 
A

angus404

I changed all of the ActiveProject references to pj, and I still get the same
error at the same line of code. I get the same error if I try to access any
properties of pj.

Any other ideas?
 
R

Rod Gill

Haven't come across that before. If you swap to Project, is the project
still active? Does ?ActiveProject.CurrentView (then press Enter) produce a
result in the Immediate Window?

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 
A

angus404

I set a breakpoint on the first line of the Project_BeforeSave event. If I
return to the project window, the project is still there. If I
?ActiveProject.CurrentView in the Immediate Window I ge the same Run-time
error '1004'.

I get this same error when I access any properites of ActiveProject or pj.

Brad
 
R

Rod Gill

What Service Pack do you have? If you are running Project Server as well,
you have to stay in sync with project Server. Otherwise, try downloading and
installing SP2

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 
A

angus404

Both client and server are SP2.

Rod Gill said:
What Service Pack do you have? If you are running Project Server as well,
you have to stay in sync with project Server. Otherwise, try downloading and
installing SP2

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 
V

Vaso Vukovic

Did you get it resolved at the end??

If it makes you feel any better, I get the same error. We're on 2007 SP1 +
Feb CU on the client side and been trying to resolve this bug since December..

On my end, the error is intermittent though. It happens in very irregular
patterns. It also occurs when working in offline mode (using your cache that
is) or VPN so I can't blame Project Server. We have about a dozen users
experiencing this issue out of 100, intermittently.
 
B

BrooksNole

Were you able to get this resolved? We started experiencing the error when
we upgraded to SP2. Most of the other office applications have this error
when the "Trust Access to Visual Basic Project" option is not set. It's
currently greyed out and if that is it I'm not sure if you can set that
programmatically or via hot key.
 

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