One of my functions is as a scheduler in the engineering/construction
industry. The premier scheduling program is Primavera P3 - very
capable scheduling program but horribly when it comes to graphics. I
started to use the method of shading cells to represent schedule
graphics, but the limitation of 255 columns can be quite limiting
(only about 70% of a calendar year or just over a year for workdays)
If you are tracking a project greater than this timeframe then this
methodology will not work.
I have developed another method for producing bars from autoshapes to
stretch over columns which represent any timeframe I want. Without
getting into all the code (because the code I have written is pretty
user unfriendly due to my amateur status) here is the concept I used.
The key code is the following:
MyDocument.Shapes.AddShape(msoShapeRectangle, FromLeft, FromTop,
BlockWidth, BlockHeight).Select
Where:
FromLeft is the distance from the left side of the sheet to the left
side of the drawn object
FromTop is the distance from the top of the sheet to the top of the
drawn object.
BlockWidth is the width of the drawn object
BlockHeight is the height of the block
Calculation for the FromLeft value is as simple as a loop to check
the date of each column timeframe which the start date would fall.
(For example: if each column is 1 month then the date within the
header cell may be mm/1/yy (and formatted as mmm-yy) and I would loop
through each header cell until my month and year for start are the
same as the month and year for the header cell. I could then use the
left value of that header cell or get more specific by taking the
left value of the cell and adding the percentage of the cell width
based upon the ratio of start day / number of days in month)
Calculation of the BlockWidth is the same as FromLeft, except to use
the finish date to do the lookup and then taking the difference
between the finish date left - start date left.
Calculation of the FromTop and BlockHeight would be the top value and
row height of the row in which the bar is to be placed. This can be
further refined to use a slightly larger top value and slightly
smaller height value to get a bar within the row rather than the
entire height of the row.
This process can be looped for as many activities as you have. Start
or Finish Milestones (lines with only one date value) can be treated
differently with a different autoshape (myself, I use a Diamond with
width equal to height and left value with a further deduction of half
the width to center the diamond on the date) You can also use a code
field to designate what color or pattern the shape should have.
Areas of complication:
Start date must be earlier than finish dates or checked to see if the
two dates are the same.