PC Review


Reply
Thread Tools Rate Thread

Aligning a connector to a cell edge?

 
 
=?Utf-8?B?RGFu?=
Guest
Posts: n/a
 
      14th Mar 2007
I would like to use a connector (like msoConnectorElbow), but without any
shapes in the project. I want to align the connector (beginning and end
points) to corners of cells.
The connector object needs coordinates in points. Is there a way to generate
the x,y points based on the cell that I want to align it with?

Thanks!
dan
 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      14th Mar 2007
Dan,
Try this.
The help is somewhat misleading, as it states:
"EndX Required Single. The horizontal position (in points) of the
connector's end point relative to the upper-left corner of the document."

However, it seems that it is really relative to the start X and Y, not the
document.
You could add another argument to the function to dictate the type of
alignment required; this just assume right and left, centred.

Private Type RECT
x1 As Single
y1 As Single
x2 As Single
y2 As Single
End Type

Private Sub CommandButton1_Click()

Call AddConnectorByRanges(Range("B4"), Range("H22"))

End Sub


Public Function AddConnectorByRanges(StartRange As Range, _
EndRange As Range, _
Optional ConType As MsoConnectorType
= msoConnectorElbow) _
As Boolean
Dim Coords As RECT

With StartRange
Coords.x1 = .Left + .Width
Coords.y1 = .Top + .Height / 2
End With

With EndRange
Coords.x2 = .Left - Coords.x1
Coords.y2 = (.Top + .Height / 2) - Coords.y1
End With

With Coords
ActiveSheet.Shapes.AddConnector ConType, .x1, .y1, .x2, .y2
End With

End Function

NickHK

"Dan" <(E-Mail Removed)> wrote in message
news:C614363E-5146-436C-B309-(E-Mail Removed)...
> I would like to use a connector (like msoConnectorElbow), but without any
> shapes in the project. I want to align the connector (beginning and end
> points) to corners of cells.
> The connector object needs coordinates in points. Is there a way to

generate
> the x,y points based on the cell that I want to align it with?
>
> Thanks!
> dan



 
Reply With Quote
 
=?Utf-8?B?RGFu?=
Guest
Posts: n/a
 
      15th Mar 2007
Thanks Nick!
On a related note... how to set the width of a connector (msoConnectorElbow)?
I tried .. connectorFormat.width = x

and similar things. Can't find anything in the connector properties reference.

Dan

"NickHK" wrote:

> Dan,
> Try this.
> The help is somewhat misleading, as it states:
> "EndX Required Single. The horizontal position (in points) of the
> connector's end point relative to the upper-left corner of the document."
>
> However, it seems that it is really relative to the start X and Y, not the
> document.
> You could add another argument to the function to dictate the type of
> alignment required; this just assume right and left, centred.
>
> Private Type RECT
> x1 As Single
> y1 As Single
> x2 As Single
> y2 As Single
> End Type
>
> Private Sub CommandButton1_Click()
>
> Call AddConnectorByRanges(Range("B4"), Range("H22"))
>
> End Sub
>
>
> Public Function AddConnectorByRanges(StartRange As Range, _
> EndRange As Range, _
> Optional ConType As MsoConnectorType
> = msoConnectorElbow) _
> As Boolean
> Dim Coords As RECT
>
> With StartRange
> Coords.x1 = .Left + .Width
> Coords.y1 = .Top + .Height / 2
> End With
>
> With EndRange
> Coords.x2 = .Left - Coords.x1
> Coords.y2 = (.Top + .Height / 2) - Coords.y1
> End With
>
> With Coords
> ActiveSheet.Shapes.AddConnector ConType, .x1, .y1, .x2, .y2
> End With
>
> End Function
>
> NickHK
>
> "Dan" <(E-Mail Removed)> wrote in message
> news:C614363E-5146-436C-B309-(E-Mail Removed)...
> > I would like to use a connector (like msoConnectorElbow), but without any
> > shapes in the project. I want to align the connector (beginning and end
> > points) to corners of cells.
> > The connector object needs coordinates in points. Is there a way to

> generate
> > the x,y points based on the cell that I want to align it with?
> >
> > Thanks!
> > dan

>
>
>

 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      15th Mar 2007
Dan,
Recording a macro of the formatting I got:

Sub Macro1()
ActiveSheet.Shapes.AddConnector(msoConnectorElbow, 169.5, 58.5, 132#,
132.75).Select
Selection.ShapeRange.Fill.Transparency = 0#
Selection.ShapeRange.Line.Weight = 1.25
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.ConnectorFormat.Type = msoConnectorElbow
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoTrue
Selection.ShapeRange.Line.ForeColor.SchemeColor = 64
Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
Selection.ShapeRange.Line.BeginArrowheadLength =
msoArrowheadLengthMedium
Selection.ShapeRange.Line.BeginArrowheadWidth = msoArrowheadWidthMedium
Selection.ShapeRange.Line.BeginArrowheadStyle = msoArrowheadNone
Selection.ShapeRange.Line.EndArrowheadLength = msoArrowheadLengthMedium
Selection.ShapeRange.Line.EndArrowheadWidth = msoArrowheadWidthMedium
Selection.ShapeRange.Line.EndArrowheadStyle = msoArrowheadNone
End Sub

NickHK


"Dan" <(E-Mail Removed)> wrote in message
news:BBB3AA96-072A-4386-B71F-(E-Mail Removed)...
> Thanks Nick!
> On a related note... how to set the width of a connector

(msoConnectorElbow)?
> I tried .. connectorFormat.width = x
>
> and similar things. Can't find anything in the connector properties

reference.
>
> Dan
>
> "NickHK" wrote:
>
> > Dan,
> > Try this.
> > The help is somewhat misleading, as it states:
> > "EndX Required Single. The horizontal position (in points) of the
> > connector's end point relative to the upper-left corner of the

document."
> >
> > However, it seems that it is really relative to the start X and Y, not

the
> > document.
> > You could add another argument to the function to dictate the type of
> > alignment required; this just assume right and left, centred.
> >
> > Private Type RECT
> > x1 As Single
> > y1 As Single
> > x2 As Single
> > y2 As Single
> > End Type
> >
> > Private Sub CommandButton1_Click()
> >
> > Call AddConnectorByRanges(Range("B4"), Range("H22"))
> >
> > End Sub
> >
> >
> > Public Function AddConnectorByRanges(StartRange As Range, _
> > EndRange As Range, _
> > Optional ConType As

MsoConnectorType
> > = msoConnectorElbow) _
> > As Boolean
> > Dim Coords As RECT
> >
> > With StartRange
> > Coords.x1 = .Left + .Width
> > Coords.y1 = .Top + .Height / 2
> > End With
> >
> > With EndRange
> > Coords.x2 = .Left - Coords.x1
> > Coords.y2 = (.Top + .Height / 2) - Coords.y1
> > End With
> >
> > With Coords
> > ActiveSheet.Shapes.AddConnector ConType, .x1, .y1, .x2, .y2
> > End With
> >
> > End Function
> >
> > NickHK
> >
> > "Dan" <(E-Mail Removed)> wrote in message
> > news:C614363E-5146-436C-B309-(E-Mail Removed)...
> > > I would like to use a connector (like msoConnectorElbow), but without

any
> > > shapes in the project. I want to align the connector (beginning and

end
> > > points) to corners of cells.
> > > The connector object needs coordinates in points. Is there a way to

> > generate
> > > the x,y points based on the cell that I want to align it with?
> > >
> > > Thanks!
> > > dan

> >
> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Aligning within a cell T. Valko Microsoft Excel Worksheet Functions 2 5th Dec 2006 09:40 PM
Aligning decimal numers to the centre of the cell and aligning dec =?Utf-8?B?UmFtZXNoIEJhYnU=?= Microsoft Excel Misc 1 1st Jul 2006 10:33 PM
Is is possible to set a border NOT on the edge of a cell? Abraham.Olson@gmail.com Microsoft Excel Programming 1 23rd Jun 2006 03:29 AM
Aligning connector lines =?Utf-8?B?RWxhaW5l?= Microsoft Powerpoint 2 15th Aug 2005 05:33 AM
Re: Aligning a graphic in the footer along the left edge. Debra Dalgleish Microsoft Excel Misc 0 30th Jul 2004 01:54 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:44 AM.