Gantt Bar Style table length?

G

G Lykos

Greetings! Have written a small program to set Gantt chart milestone
symbols to a frame StartType if not complete, solid if complete. Have
settled upon looping through the i Items defined styles for milestone tasks
via GanttBarStyleEdit. It appears that this table can have up to 40
entries.

Question: How can I determine the length of the defined styles list?
Problem is that if I set i to the maximum possible, the code chokes when it
goes beyond the defined styles, but the number of defined styles is variable
and file-specific. However, I don't see how to read the list to test the
Items for existence, or see a .count attribute, or other handle.

Thanks,
George
 
G

G Lykos

Further, I'm using a brute-force approach of setting all StartTypes in
milestone tasks to framed or solid because I don't know how to read each
style entry to find the diamond, the only shape I really wish to manipulate.
Is there a way to read the contents of the style table?

Thanks again!
 
J

John

G Lykos said:
Further, I'm using a brute-force approach of setting all StartTypes in
milestone tasks to framed or solid because I don't know how to read each
style entry to find the diamond, the only shape I really wish to manipulate.
Is there a way to read the contents of the style table?

Thanks again!

George,
Many of the formatting methods in Project do not have a full complement
of properties for VBA. The GanttBarstyleEdit Method is one of those. For
example, as far as I know it does not have a list.count syntax so you
have to use indirect methods.

I recently wrote a macro that did a massive amount of formatting and
setting the Gantt Bar styles was one of the items addressed. I elected
to go through a simple delete loop to first clear the existing formats
and then systematically added in the new styles. It might be similar to
the brute force method you are using but for reference, here is the code
I used to clear the bar formats. Note: I used 15 for the loop counter
because as I recall there are only 15 default bar styles.

On Error Resume Next
For i = 1 To 15
GanttBarStyleDelete (1)
If Err > 0 Then
Err.Clear
Exit For
End If
Next i

John
Project MVP
 
G

G Lykos

Thanks, John. Your example got me thinking, and after poking around a
little realized that On Error Resume Next allows sizing a brute-force loop
for the style table size of 40, then proceeding with GanttBarStyleEdit for
items 1-40, setting each either frame or solid depending on completion
status, and not blowing up when the loop runs past the end of items in the
table.

Out of curiosity - after having set On Error Resume Next ahead of a block of
code, would you know how to I can revert to the original error-handling
state after it?

Thanks again,
George
 
G

G Lykos

John, please disregard my question about resetting the On Error behavior -
re-read the Help and it finally sank in that On Error GoTo 0 returns to the
original state.

Regards,
George
 
J

John

G Lykos said:
John, please disregard my question about resetting the On Error behavior -
re-read the Help and it finally sank in that On Error GoTo 0 returns to the
original state.

Regards,
George
George,
Yes that's correct. I guess I didn't copy the On Error GoTo 0 part of
the code snippet when I pasted it into my response. I use that
combination often in my macros.

John
Project MVP
 

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