View Single Post
 
Old 04-29-2015, 05:57 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,635
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

You might need to tweak it a bit, but try this:

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oRng As Word.Range
Dim lngCount As Long, lngCounted As Long
  lngCount = InputBox("Enter the number of words to move", "Move Cursor X Words", 10)
  Set oRng = Selection.Range
  On Error GoTo Err_Handler
  Do
    Debug.Print oRng.Words.Last.Next
    If Len(oRng.Words.Last.Next) > 1 Then
       oRng.Move wdWord, 1
    Else
      If oRng.Words.Last.Next Like "[.,;:\!]" Then
        If lngCounted = lngCount - 1 Then
          oRng.Move wdWord, 1
        Else
          oRng.Move wdWord, 2
        End If
      Else
        oRng.Move wdWord, 1
      End If
    End If
    lngCounted = lngCounted + 1
  Loop Until lngCounted = lngCount
lbl_Exit:
  oRng.Select
  Exit Sub
Err_Handler:
  MsgBox "There is not that many words!"
  Resume lbl_Exit
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote