Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default VBA draw and erase lines (crosshairs) on form

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default VBA draw and erase lines (crosshairs) on form

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


"gary" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default VBA draw and erase lines (crosshairs) on form

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


"Greg Wilson" wrote:

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


"gary" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to draw lines of SPC Daniel Charts and Charting in Excel 4 July 31st 07 08:44 PM
Erase & Draw Border functions no longer work bob m Excel Discussion (Misc queries) 2 February 25th 05 06:03 PM
Draw lines in a userform gbottesi Excel Programming 3 July 8th 04 05:20 PM
How to draw a object and erase it programmatically Simon Lenn Excel Programming 3 May 15th 04 01:22 AM
How do I draw lines..?? MIKEB Excel Programming 4 October 24th 03 12:22 AM


All times are GMT +1. The time now is 02:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"