PDA

View Full Version : Solved: addTextBox: how to find points from top/left of a specific cell?



GreenTree
09-15-2007, 04:10 PM
Just starting to play with adding textboxes to a worksheet with code. The addTextBox method seems pretty straightforward, although you have to give it the position of the upper left corner of your new textbox, measured in points, relative to the top/left corner of the worksheet. Let's say that I want to position the top left corner of my textbox directly at the top left corner of a cell known only as Row=R and Column = C. Is there a quick way to determine the # of points down and left, given R and C?

I'm guessing that one could sum the prior rows heights and the prior columns widths with a For/Next loop; is that the best bet, or is there a better way to do it? Are there any non-obvious gotchas with the for/next approach?

Thanks,

G.T.

Bob Phillips
09-15-2007, 04:58 PM
As an example



With Range("G5")
ActiveSheet.OLEObjects.Add(ClassType:="Forms.TextBox.1", _
Link:=False, _
DisplayAsIcon:=False, _
Left:=.Left, _
Top:=.Top, _
Width:=66, _
Height:=33).Select
.Select
End With

GreenTree
09-15-2007, 05:39 PM
Exactly what I needed. Many thanks!

Solved!

Best wishes,

G.T.