Word: How to you determine the current cursor position
For one of my macros to run, I have to ensure that the cursor position is not in a table or in a frame when the user activates the macro.
How can I find our the current cursor position? Once I can determine that the cursor is positioned in a table or a frame, I can then code a message box to instruct the user where to put their cursor to run a certain routine.
[377 byte] By [
KatKen] at [2007-12-28]
Hi,
Cursor position
Selection.Range.End
This will check whether currently in a table or frame.
Dim lngTableCount As Long
Dim lngFrameCount As Long For lngTableCount = 1 To ActiveDocument.Tables.Count
If Selection.Range.InRange(ActiveDocument.Tables(lngTableCount).Range) Then
MsgBox "In Table"
Exit For
End If
Next
For lngFrameCount = 1 To ActiveDocument.Frames.Count
If Selection.Range.InRange(ActiveDocument.Frames(lngFrameCount).Range) Then
MsgBox "In Frame"
Exit For
End If
Next