[vba] is there a flag whether this summary task is collpased or no

  • Thread starter How to detect collapsed task in vba?
  • Start date
H

How to detect collapsed task in vba?

I'm importing MS Project 2003 data into Excel rows.
If a certain summary task is collpased (+signed in msp), I want to skip
these tasks without displaying in excel rows.
I could not find any property name showing this, hopely (.collapsed)
Is there I can identify collapsed status?
 
J

Jack Dahlgren

You don't really need to determine this. Just select the tasks visible in
the current view and then work with that selection:

Dim myselect As Selection
SelectAll
Set myselect = ActiveSelection
For Each Task In myselect.Tasks
'export data to excel
next task
--
Jack Dahlgren
Project Blog: http://zo-d.com/blog
Macros: http://masamiki.com/project/macros.htm



"How to detect collapsed task in vba?" <How to detect collapsed task in
[email protected]> wrote in message
news:[email protected]...
 
H

How to detect collapsed task in vba?

Thanks for your response. It looks good idea if I wrote in MS Project VBA.
But this vba is written in Excel because of some more logics are needed in
Excel.
Sorry making you confused.
Any idea in excel vba to know the collapsed status?
 
J

Jan De Messemaeker

Hi,

You have to use the Project objects.
In Excel VBA make a reference to Project
-In VB Editor, tools, references, add the reference to MS project
Start the codfe as follows
Dim PJApp as MSProject.application
set PJApp=createobject("MSProject.Application")
From there on you can now use all MS project objects for instance
PJApp.activeproject.tasks
etcetera

HTH

--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
"How to detect collapsed task in vba?"
 
H

How to detect collapsed task in vba?

It worked, thanks.
Only difference is your
'export data to excel
has been changed to
for each selection in activeselection

I wrote in Excel vba to read ms project and main idea was giving the
selection criteria. Previous was for all tasks in msp
 
H

How to detect collapsed task in vba?

Ooops, I still have a problem when I rebooted the system and retried.
In my Excel vba,

Set myProject = GetObject(MppFile)
SelectAll <======= debug says <this command is not applicable now.(?)>
Set mySelection = ActiveSelection
For Each myTask In mySelection.Tasks
. . .
Next

It worked, but not now -_-.
Anything missed in my code?
 
J

Jack Dahlgren

"How to detect collapsed task in vba?"
It worked, thanks.
Only difference is your
'export data to excel
has been changed to
for each selection in activeselection

I would use for each Task in myselection.tasks.
You probably want to work with a task object rather than a selection. I
always do.
Set myProject = GetObject(MppFile)
SelectAll <======= debug says <this command is not applicable
now.(?)>

Try myProject.activate

This should bring it to the forefront.

-Jack
 
R

Rod Gill

I think the Selectall method is at the application level, not project level.
Code needed is therefore:
Sub Test()
Dim projApp As MSProject.Application
Dim Tsk As Task

Set projApp = GetObject(, "MSProject.Application")
projApp.SelectAll
For Each Tsk In projApp.ActiveSelection

Next Tsk
End Sub


--

Rod Gill
Project MVP

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

NEW!! Web based VBA training course delivered by me. For details visit:
http://projectservertraining.com/learning/index.aspx
 

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