Preserving Gantt Bar Styles

B

Bill Bordiuk

What I'd like to do is create a new Gantt Bar Style if one doesn't exist for
some named set of criteria. However, if someone has already set a style for
that named set of criteria, I'd like to leave it alone. For example, the
criteria would be named 'Critical' and would show the bar in a certain style
if the Critical flag was set. I have a template that sets up those initial
criteria and I have code that implements the criteria on projects that
weren't created with the template. The problem is when users change the bar
style associated with the criteria. As soon as my code runs, depending on
how I've implemented it, it either modifies the user's changes or adds a new
set of bar styles (with the same names) that override the user's changes.

Is there any way to tell if a given (named) bar style exists?

Thanks,

Bill Bordiuk
 
S

Steve P

If you want to test if a style of a certain name exists then this
should work for you

e.g if sjpStyleExist(strStyleName:="NameToTest") then
' do something
end if


regards
Steve

Public Function sjpStyleExist(strStyleName As String) As Boolean
'
On Error Resume Next
' Try to edit the style and see if an error occurs.
' If it does the style does not exist
' Ensure error object starts clean
Err.Clear
' Try and edit the style (without changing anything)
GanttBarStyleEdit Item:=strStyleName
' If we got an error
If Err.Number > 0 Then
' The style does not exist
StyleExist = False
Else
' No error, so we have a valid style
StyleExist = True
'
End If
'
On Error GoTo 0
'
End Function
 

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