Date fnction throws error one one file

J

Joy

We have the following code to format Start and Finish for each task as
'MM/DD/YYYY':

Dim tsk As Task
For Each tsk In proj.Tasks
' On Error Resume Next
If Not tsk Is Nothing Then
tsk.Text10 = Month(tsk.Start) & "/" & Day(tsk.Start) & "/" &
Year(tsk.Start)
tsk.Text11 = Month(tsk.Finish) & "/" & Day(tsk.Finish) & "/" &
Year(tsk.Finish)
End If
Next tsk

A user reported a case to us and it always throws "Run Time Error: 1004" on
that file. I can see no problem with the Project file. Whichever task format
I select Tools -> Options -> View -> Date Format, I always get the error.
However, I have no issue with other files with the same formats.

can any one give an idea of why?
 
R

Rod Gill

I think this error is a symptom of something else. On their login/pc in the
VBE look at the references under Tools menu. A reference may be broken.

For date formats the following code is more flexible and useful:
tsk.Text10 = Format(tsk.Start,"mm/dd/yy")


--

Rod Gill
Microsoft MVP for Project - http://www.project-systems.co.nz

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




Joy said:
We have the following code to format Start and Finish for each task as
'MM/DD/YYYY':

Dim tsk As Task
For Each tsk In proj.Tasks
' On Error Resume Next
If Not tsk Is Nothing Then
tsk.Text10 = Month(tsk.Start) & "/" & Day(tsk.Start) & "/" &
Year(tsk.Start)
tsk.Text11 = Month(tsk.Finish) & "/" & Day(tsk.Finish) & "/" &
Year(tsk.Finish)
End If
Next tsk

A user reported a case to us and it always throws "Run Time Error: 1004"
on
that file. I can see no problem with the Project file. Whichever task
format
I select Tools -> Options -> View -> Date Format, I always get the error.
However, I have no issue with other files with the same formats.

can any one give an idea of why?

__________ Information from ESET Smart Security, version of virus
signature database 5022 (20100412) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 5022 (20100412) __________

The message was checked by ESET Smart Security.

http://www.eset.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