Center Text on Point

  • Thread starter Thread starter Richard
  • Start date Start date
R

Richard

I'm using a macro to drawing lines and then adding text labels to the lines.

The text has variable lengths. Right now I'm adding the text so that the
left top of the text box corresponds to the 1/2 point of the line.

How can I center theh text on a specific point (for example the 1/2 way
point on a line)?
 
Maybe something like this

Sub test2()
Dim ctrHz As Double, ctrVt As Double

With ActiveSheet.Shapes("Line 1")
ctrHz = .Left + .Width / 2
ctrVt = .Top + .Height / 2
End With

With ActiveSheet.Shapes("Text Box 2")
.Left = ctrHz - .Width / 2
.Top = ctrVt - .Height / 2
End With

End Sub

You might want to format your textbox's Autosize property = true

Regards,
Peter T
 

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

Back
Top