LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.office.developer.automation,microsoft.public.access
external usenet poster
 
Posts: 169
Default Visually represent project dates and activities as shapes in Excel

Actually, this turns out to be relatively simple; the key is knowing what
cells you want to draw the lines or boxes between, which is trivial really.

1. Each cell has .Left, .Top, .Width and .Height properties, so to
determine the start and end points of the line/box you use something like:

Set sht = xlApp.ActiveWorksheet
lngLineLeft = sht.Cells(intRow, intStartCol).Left
lngLineRight = sht.Cells(intRow, intEndCol).Left + sht.Cells(intRow,
intEndCol).Width

Same sort of thing for getting the top and bottom position of the line or
box you want to draw

2. Then you use the one of the Shapes.AddXXXX methods to add the shape to
that position on the spreadsheet. Below, I've listed the code I used to add
a line, a box. Additionally, since I wanted a mouseover or control tip text
type capability, I also added hyperlinks (that go nowhere)

With sht.Shapes.AddLine(lngLineLeft, lngLineCenter, lngLineRight,
lngLineCenter).Line
.Weight = 3
.DashStyle = msoLineSolid
.ForeColor.RGB = RGB(128, 128, 128)
End With

If IsNull(TipText) = False Then
sht.Hyperlinks.Add sht.Shapes(sht.Shapes.Count), "", "", TipText
End If

Set shpBox = sht.Shapes.AddShape(msoShapeRound1Rectangle, lngBoxLeft,
lngBoxTop, lngBoxRight - lngBoxLeft, 15)
With shpBox
.Fill.BackColor.RGB = RGB(121, 121, 113)
.Fill.Transparency = 0.5

sht.Hyperlinks.Add shpBox, "", "", "Place your hyperlink text here"

End With

3. Lastly, I wanted to be able to associate a label with each of the boxes,
so I used the code below:

Set shpLabel = sht.Shapes.AddTextbox(msoTextOrientationHorizontal ,
lngBoxLeft, lngBoxTop + 9, lngBoxRight - lngBoxLeft, 15)
With shpLabel
.TextEffect.Text = IIf(Milestone = "Event dates", "Main event",
Milestone)
.TextFrame.AutoSize = True
.TextEffect.FontBold = msoTrue
.TextEffect.FontSize = 10
End With

Hope this helps the next guy that wants to try something like this.

Dale




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Excel with Visually Impaired and ZoomText Daniel Naas Setting up and Configuration of Excel 0 April 3rd 08 06:17 PM
Visually Impaired Using Excel with ZoomText Daniel Naas[_2_] Excel Discussion (Misc queries) 0 April 3rd 08 06:08 PM
Calculating an Activities During Periods Of Natural Months and/or Dates Rayco Excel Worksheet Functions 1 October 10th 05 01:30 PM
setting excel visually AmyTaylor[_25_] Excel Programming 2 August 31st 05 03:34 PM
Can not visually see the shading on the EXCEL file? lloyd Excel Discussion (Misc queries) 1 April 12th 05 12:59 PM


All times are GMT +1. The time now is 12:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"