Exporting Hierarchy to Excel (Jack`s Macro)

B

Bahareh

Hello

I need to export hierarchy to excel. I used Jack Dahlgren`s VBA macro but it
doesn`t work. (I cheched Microsoft excel library ... in resource/tools menue).
It shows a message box which say:

"
Run-time error (424)
Object Requierd
"
In debug window The line which is shown yellow is in the last lines.

"
Sub dwn (i As integer)
Set xlrow=xlrow.offset(i,o)
End sub
"

I selected the tasks and runed the Macro but The problem still exist.
Can anybody help me? Jack may you solve the problem?

Thanks
 
J

John

Bahareh said:
Hello

I need to export hierarchy to excel. I used Jack Dahlgren`s VBA macro but it
doesn`t work. (I cheched Microsoft excel library ... in resource/tools menue).
It shows a message box which say:

"
Run-time error (424)
Object Requierd
"
In debug window The line which is shown yellow is in the last lines.

"
Sub dwn (i As integer)
Set xlrow=xlrow.offset(i,o)
End sub
"

I selected the tasks and runed the Macro but The problem still exist.
Can anybody help me? Jack may you solve the problem?

Thanks

Bahareh,
Jack's code does run - I just tried it myself. One thing I did note
however is that when I copied and pasted the code from Jack's website
into the VB Editor, I had to do some editing to satisfy the complier.
The copy and paste process apparently introduced some hidden tabs or
other characters that had to be edited out. Whenever code is edited like
that it is fairly easy to inadvertently delete a line of code. It sounds
like that is what happened to you. I would check the code in your VB
editor and make sure it has all the lines that are shown on Jack's
website.

John
Project MVP
 
B

Bahareh

Hello

I checked the code that I pasted into VB editor, all the lines exist and
also the problem still exists. Another problem is occured in the line
following here:

Sub TaskHierarchy()
Dim xlApp As Excel.Application

Error says That it isn`t defiend.

what is wrong with my Pj Plan? What can I do?

Thanks
 
J

Jan De Messemaeker

Hi,

This one is easy, I'll take it straightaway
In the VB Editor, go to Tools, References, look for Microsoft Excel and
check the checkbox.
HTH
 
B

Bahareh

Oh yes. I forgot to do that so one problem solved. But the problem in last
lines still exist:

Sub dwn (i As integer)
Set xlrow=xlrow.offset(i,o)
End sub

The error message mentioned:

"Run-time error (424)
Object Requierd"

What Can I do?

Thanks for your response
 
J

John

Bahareh said:
Oh yes. I forgot to do that so one problem solved. But the problem in last
lines still exist:

Sub dwn (i As integer)
Set xlrow=xlrow.offset(i,o)
End sub

The error message mentioned:

"Run-time error (424)
Object Requierd"

What Can I do?

Thanks for your response

Bahareh,
Your original post specifically said that you set the reference to the
Excel object library so how did it get un-set? Once it is set for a
module, it doesn't need to be set again unless a new module is created.

With regard to your existing problem, the error message is pointing to
the fact that "xlrow" is not defined as a valid object. Try this, at the
very beginning of the code are the following two lines:
Dim xlRow As Excel.Range
Dim xlCol As Excel.Range

Change those lines to the following:
Public xlRow As Excel.Range
Public xlCol As Excel.Range

Now try it. Does it work?

John
Project MVP
 
B

Bahareh

Hello John

the reason that the setting was not accessable was that I always save a
version for myself and then try new macros (anyway the affects are unknown).

Thanks John For your guide, But problem stiil exist. Now an empty Excel
sheet opens and when I close it, It give me Error 424 and ask me to debug 2d
line of following set:

Sub dwn(i As Integer)
Set xlRow = xlRow.Offset(i, 0)
End Sub

{{I don`t know VBA but I realy need to transfer hierarchy to Excel. Because
there are more than 2500 tasks in Pj plan which relate to all the departments
and some of them don`t know MSP but they change my MSP plan (sometimes they
change duration or even predecessors to reach their planned finish date! if
these happen, No variance report is needed!) . I don`t want to let them such
inlogical changes. That is why I want to transfer the tasks to Excel and give
them Excel Version.}}


I will be greatfull if you solve my Problem.

Thanks
 
J

John

Bahareh said:
Hello John

the reason that the setting was not accessable was that I always save a
version for myself and then try new macros (anyway the affects are unknown).

Thanks John For your guide, But problem stiil exist. Now an empty Excel
sheet opens and when I close it, It give me Error 424 and ask me to debug 2d
line of following set:

Sub dwn(i As Integer)
Set xlRow = xlRow.Offset(i, 0)
End Sub

{{I don`t know VBA but I realy need to transfer hierarchy to Excel. Because
there are more than 2500 tasks in Pj plan which relate to all the departments
and some of them don`t know MSP but they change my MSP plan (sometimes they
change duration or even predecessors to reach their planned finish date! if
these happen, No variance report is needed!) . I don`t want to let them such
inlogical changes. That is why I want to transfer the tasks to Excel and give
them Excel Version.}}


I will be greatfull if you solve my Problem.

Thanks

Bahareh,
Well the good news is I have a solution for your real problem and it
doesn't involve VBA in any way. Now that you explained your end goal,
the main issue here is training for your users. We get a fair number of
posts similar to yours where someone who is responsible for project
management is trying to develop a method for keeping their users from
making unauthorized changes to Project files. Although there are ways to
incorporate auditing into the process (and auditing should be available
as a backup), by far the best solution to the problem is to adequately
train all Project users both on how to use Project and even more
importantly, on your corporate rules. For example, if users are informed
during training that certain Project fields are not to be edited because
the field is reserved for the project manager's use, then they have a
better understanding of what to do and what not to do. If some users
insist on making unauthorized changes then it is an issue to be brought
up with their supervision. Most employees want to do a good job and are
perfectly willing to follow the rules as long as those rules are clearly
laid out and are reasonable. Teamwork trumps conflict every time.
Granted, there may still be an occasional slip and a user may
inadvertently make an unauthorized change. That's why it is good
practice to have some auditing tools available. Most of the auditing can
be some with some fairly simple filters that can readily isolate
potential problem areas. More advanced auditing can be done with custom
VBA macros or by using the built-in utility, Compare Project Versions.

OK, that's the lecture. The problem you are having with Jack's code is
rather unusual. As far as I know, it has been used by a whole lot of
users with no issues. That makes me think that perhaps your setup is
unusual in some way. Since I can't replicate your problem I can only
guess at some things.

1. You mentioned that Excel does open but with a blank page. Is it
really blank? At the point of failure, there should be an entry in the
A1 cell, namely the filename of the project. Do you see that?

2. From the VB editor, go to Tools/References. There should be 4 or more
references checked. What are they (list each one fully)?

3. How exactly did you copy Jack's code into the VB editor? In other
words, if you show the Project Explorer, where is the module that
contains Jack's macro?

Let's see what you have for these questions. Then we can look as some
other things.

John
Project MVP
 
B

Bahareh

Realy Thank you, John

The problem with macro solved. Answering your 3d guide question solved the
problem. It was 2 line in the new macro which was created (I don`t know why
it comes at the begining of every new macro! it contains "Format duration" -I
thought that it is natural but when I deleted it, macro works perfect)

changing the 2 line which contains "Dim" to "public" solved my problem.

I agree with you about training.

In our custom we say "From every hand you give ,from the other hand you will
give". Thank you.

(be sure I will ask more qustion about MSP later :))

have successful life
 
J

John

Bahareh said:
Realy Thank you, John

The problem with macro solved. Answering your 3d guide question solved the
problem. It was 2 line in the new macro which was created (I don`t know why
it comes at the begining of every new macro! it contains "Format duration" -I
thought that it is natural but when I deleted it, macro works perfect)

changing the 2 line which contains "Dim" to "public" solved my problem.

I agree with you about training.

In our custom we say "From every hand you give ,from the other hand you will
give". Thank you.

(be sure I will ask more qustion about MSP later :))

have successful life

Bahareh,
Ah, the old rogue lines problem. Yeah, that will do it every time. I'm
glad you finally figured it out.

I guess I've had a successful live - I'm still alive :)

You're welcome and thanks for the feedback.
John
 
R

Rhammia Immanuel

Bahareh,
Would appreciate if you can give me the working code for the
Task export to Excel. I am having the same trouble.

Thanks.
 
J

JulieS

Hi Rhammia,

The source for the code is at:
http://masamiki.com/project/macros.htm

Look for the macro "Export Hierarchy to Excel" Please note that the
Excel Object Library is selected.

I suggest you post the lines of code from the De-bugger which are
causing the problem.

--
I hope this helps. Let us know how you get along.

Julie

Visit http://project.mvps.org/ for FAQs and more information about
Microsoft Project.
 
M

mperry29

Is there anyway to make this macro accept larger project names? We have
projects saved with move than 31 characters, and it seems to make the macro
very unhappy!!!
 
J

John

mperry29 said:
Is there anyway to make this macro accept larger project names? We have
projects saved with move than 31 characters, and it seems to make the macro
very unhappy!!!

"Bahareh" wrote:

Barareh,
It's not the macro that is having a problem, it's Excel. Excel will only
accept sheet names of 31 characters or less. I suggest you abbreviate
your project file name.

As an alternate you could comment out the line,
xlSheet.Name = ActiveProject.Name

John
Project MVP
 
J

Jack Dahlgren

Thanks John,
Good catch.

-Jack Dahlgren

John said:
Barareh,
It's not the macro that is having a problem, it's Excel. Excel will only
accept sheet names of 31 characters or less. I suggest you abbreviate
your project file name.

As an alternate you could comment out the line,
xlSheet.Name = ActiveProject.Name

John
Project MVP
 
J

John

Jack Dahlgren said:
Thanks John,
Good catch.

-Jack Dahlgren

Jack,
I had to run it myself to see just what he meant by your macro being
"very unhappy". I personally find your macros to be full of joy :)

I also don't know why anyone needs a filename that is more than 31
characters long, but I guess some users want to tell the whole story in
the title.

John
 

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