VBA draw and erase lines (crosshairs) on form

G

Guest

Using VBA, I need to create full form crosshairs that will extend to the top
and sides of the form. When the user moves the mouse the crosshairs move
with it making it easy to see labels at the bottom and side of the form. I
have had no success in doing this. Also the graphic on the form needs to not
be disturbed.

Thanks for your help,

Gary
 
G

Guest

If you mean a worksheet based "form" then getting a worksheet to recognize
the Mouse_Move event and to drag crosshairs is very technically challenging
and at the same time, from what I recollect, problematic. Instead, if
acceptable, I suggest adapting Bob Phillip's post from the following thread.
Note also Robert McCurdy's post:

http://tinyurl.com/m3gs7

I append my suggested adaption of Bob's post. Assumed is that the form area
is within the range "B2:Z30". For the demo, I advise making column widths and
row heights equal and giving the range an interior colour, say gray. Note
that the highlighting is not affected by selecting multiple cells within the
form area or selecting outside of the form area.

Paste to the worksheet code module:-

Const HLColor As Long = 13434879

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim r As Range, rcol As Range, rrow As Range
Set r = Me.Range("B2:Z30")
If Intersect(Target, r) Is Nothing Then Exit Sub
Set rcol = Intersect(r, Target.EntireColumn)
Set rrow = Intersect(r, Target.EntireRow)
With Target
If .Count > 1 Then Exit Sub
r.FormatConditions.Delete
With rrow
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.Color = HLColor
End With
With rcol
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.Color = HLColor
End With
.FormatConditions.Delete
End With
End Sub

Regards,
Greg
 
G

Guest

Greg,

I do not mean a worksheet based form. I am actually from Excel using VBA to
launch an IE browser that will then go to a web site to display a chart.
From this browser window, I want the cursor when it is in this window to
change to entire window cross hairs so I can accurately read the numbers at
the ends of the browser window. My problem is how to turn the mouse cursor
into cross hairs that extend to the ends of the browser window and then be
able to move the mouse around this window without disturbing the chart on the
window.

I hope that makes more sense.

Thanks for your help,

Gary
 

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

Top