drawing a line on a userform

jammoca

Banned
Joined
Nov 6, 2002
Messages
1,100
I know you can draw a line on a userform by providing the start and end co-ordinate of where you want it, but is it possible to have a UserForm appear on call, with the 1st co-ordinate already set (by the programmer) and the user clicks on some point of the UserForm to indicate where they want the end co-ordinate to be, and that a line would then be drawn to that point ?
 
Hi Andy, this is what I'm currently using (but getting the inaccurate line aim), is this what you meant ?? :

Private Function m_CreateFrame() As Shape
'
' Create a shape top left in order to keep the other
' elements in the correct offset positions
'
Dim lngColor As Long

On Error GoTo ErrCreateFrame
If m_blnUseUF Then
If m_frmUFCanvas.BackColor >= 0 Then
lngColor = m_frmUFCanvas.BackColor
Else
lngColor = m_frmUFCanvas.BackColor And &HFF
lngColor = GetSysColor(lngColor)
End If
Set m_CreateFrame = m_shtHolder.Shapes.AddShape(msoShapeRectangle, 0, 0, m_frmUFCanvas.InsideWidth - 1, m_frmUFCanvas.InsideHeight - 1)
Else
If m_objCanvas.BackColor >= 0 Then
lngColor = m_objCanvas.BackColor
Else
lngColor = m_objCanvas.BackColor And &HFF
lngColor = GetSysColor(lngColor)
End If
Set m_CreateFrame = m_shtHolder.Shapes.AddShape(msoShapeRectangle, 0, 0, m_objCanvas.Width - 1, m_objCanvas.Height - 1)
End If
With m_CreateFrame
With .Fill
.ForeColor.RGB = lngColor
.BackColor.RGB = lngColor
End With
.Line.BackColor.RGB = lngColor
.Line.ForeColor.RGB = lngColor
.ZOrder msoSendToBack
End With
Exit Function
ErrCreateFrame:
Set m_CreateFrame = Nothing
Exit Function
End Function
 
Upvote 0

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
I know you can draw a line on a userform by providing the start and end co-ordinate of where you want it, but is it possible to have a UserForm appear on call, with the 1st co-ordinate already set (by the programmer) and the user clicks on some point of the UserForm to indicate where they want the end co-ordinate to be, and that a line would then be drawn to that point ?
I know this is an old post, but a much easier way to draw an object (line, circle, or whatnot) is create the drawing on another application and copy it into a picture that you place on the user form. For example, to draw a line on a user form, draw your line in something like PowerPoint. Set the color and length and width properties to what you desire.

  • On the user form, insert an image.
  • Copy the line from PowerPoint and on the image properties, paste it in the properties field, "Picture".
  • Set the BackStyle to "Transparent"
  • Set the BorderStyle to "None"
  • Set the PictureSizeMode to "3 - fmPictureSizeModeZoom"
  • Size the image to fit on the user form

Steve
 
Upvote 0

Forum statistics

Threads
1,224,041
Messages
6,176,035
Members
452,697
Latest member
CuriousSpreadsheet

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top