Using VBA to export to Excel.

F

fxs

It is my understanding that it is possible to use VBA to export certain
fields tasks to Excel, programmatically - by running a macro.
Can someone post some sample code to that effect? What I'm looking for is
code for three scenarios, but if you can help me with one, I may be able to
figure my way around the others.
Scenario 1:
Export certain fields - wbs, task description, duration, start date, end
date, dependencies - for all tasks.

Scenario 2:
The user's selected a few tasks. Export above fields for only those tasks to
excel.

Scenario 3:
The tasks are grouped by Resources (Resource Group), Export tasks belonging
to a specific resource group to excel.

Again, sample code on any of the above will help me get started.
Additionally, the best form of help you can give me is the location of any
online samples that assist with vba/msproject programming dealing with
export to excel.

thanks!
Fxs.
 
J

JackD

Answered in microsoft.public.project
Please do not post the same question multiple times.
Thanks!
 
J

JackD

I posted in .project, but here it is again.
---------------------------
I have a few macro examples which deal with export to excel.
http://masamiki.com/project/macros.htm
The basic process of opening and writing to excel would be the same for all
of your requests. The only thing that would need to change is the code to
step through all of the groups.

Here is a brief guide to what you need to do for each scenario

scenario 1:

for each task in activeproject.tasks
'write out task.wbs, move to next cell, write out task.name ...
next task

scenario 2:

for each task in activeselection.tasks
'write out task.wbs, move to next cell, write out task.name ...
next task

scenario 3:
'open excel
'build array of resource groups
'pick the first resource group
'go through each task (using same for each task code as above)
'go through each resource in task.resources and if that
resource.resourcegroup
'equals the resource group then write the task information to excel
'go to next resource
'go to next task
'go to next resource group
'close excel

--
-Jack ... For project information and macro examples visit
http://masamiki.com/project

..
fxs said:
It is my understanding that it is possible to use VBA to export certain
fields tasks to Excel, programmatically - by running a macro.
Can someone post some sample code to that effect? What I'm looking for is
code for three scenarios, but if you can help me with one, I may be able to
figure my way around the others.
Scenario 1:
Export certain fields - wbs, task description, duration, start date, end
date, dependencies - for all tasks.

Scenario 2:
The user's selected a few tasks. Export above fields for only those tasks to
excel.

Scenario 3:
The tasks are grouped by Resources (Resource Group), Export tasks belonging
to a specific resource group to excel.

Again, sample code on any of the above will help me get started.

thanks!
Fxs.
 

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