Printing Views

G

Griswold

Hi all - I am writing a VB6 routine to return a list of all Project
views & print them. If a View is 'empty' (does not have a task or
resources associated) a printer error is generated & my process waits
for a user response. This interrupts my automation.

How can I determine if a View is 'empty' in code so I can avoid
printing blank Views???

Thanks in advance.
 
R

Rod Gill

Views are either Task or Resource based. So for Gantt charts etc use:

If projApp.ActiveProject.Tasks.Count>0 then

For Resource views use:

projApp.ActiveProject.Resources.Count>0 then
--

Rod Gill
Microsoft MVP for Project

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

Griswold

Views are either Task or Resource based. So for Gantt charts etc use:

If projApp.ActiveProject.Tasks.Count>0 then

For Resource views use:

projApp.ActiveProject.Resources.Count>0 then
--

Rod Gill
Microsoft MVP for Project

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








- Show quoted text -

I tried your suggestion but am still having difficulties.
My current project has 9 tasks. For testing purposes I am cycling
through each view & printing the view name along with the value
projApp.ActiveProject.Tasks.Count

The current results print the correct View name &
projApp.ActiveProject.Tasks.Count=9 for Every view. One of these
views is a custom view I created which has no tasks or resources
associated with it. If I try & print this View I will encounter the
problem I previously described.

BTW projApp.ActiveProject.Resources.Count = 0 for all my Views.

Any other suggestions?
Thanks for your time!
 
J

Jan De Messemaeker

Hi,

Why doesn't it have "tasks or resources associated"?
Views have tasks, resoruces, or either of these plus assignments.
OTOH, you may indeed have empty views if you have a filter that rdoesn't
return any object.

I woud therefore recommend this test:

ViewApply ...
Selectall
If not activeselection=0 then

Hope this helps,

--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
Views are either Task or Resource based. So for Gantt charts etc use:

If projApp.ActiveProject.Tasks.Count>0 then

For Resource views use:

projApp.ActiveProject.Resources.Count>0 then
--

Rod Gill
Microsoft MVP for Project

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








- Show quoted text -

I tried your suggestion but am still having difficulties.
My current project has 9 tasks. For testing purposes I am cycling
through each view & printing the view name along with the value
projApp.ActiveProject.Tasks.Count

The current results print the correct View name &
projApp.ActiveProject.Tasks.Count=9 for Every view. One of these
views is a custom view I created which has no tasks or resources
associated with it. If I try & print this View I will encounter the
problem I previously described.

BTW projApp.ActiveProject.Resources.Count = 0 for all my Views.

Any other suggestions?
Thanks for your time!
 
G

Griswold

Hi,

Why doesn't it have "tasks or resources associated"?
Views have tasks, resoruces, or either of these plus assignments.
OTOH, you may indeed have empty views if you have a filter that rdoesn't
return any object.

I woud therefore recommend this test:

ViewApply ...
Selectall
If not activeselection=0 then

Hope this helps,

--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620










I tried your suggestion but am still having difficulties.
My current project has 9 tasks. For testing purposes I am cycling
through each view & printing the view name along with the value
projApp.ActiveProject.Tasks.Count

The current results print the correct View name &
projApp.ActiveProject.Tasks.Count=9  for Every view. One of these
views is a custom view I created which has no tasks or resources
associated with it. If I try & print this View I will encounter the
problem I previously described.

BTW projApp.ActiveProject.Resources.Count = 0 for all my Views.

Any other suggestions?
Thanks for your time!- Hide quoted text -

- Show quoted text -

Thanks so much Jan for the property I could not find!

The MPApp.ActiveSelection property does return a value of '0' for my
blank (empty) views.

I have thousands of these Project files to automate so this little
interruption by the printer message was a big problem for me.
Big problem - Simple solution...... Usually the way in life!

Griswold
 

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