Thread: [Solved] move cursor
View Single Post
 
Old 07-06-2015, 03:50 AM
anand anand is offline Windows 7 64bit Office 2010 32bit
Novice
 
Join Date: Jun 2015
Posts: 15
anand is on a distinguished road
Default

Code:
Sub a()
Dim orng As Word.Range
Selection.HomeKey Unit:=wdStory
Do
  Selection.EndKey Unit:=wdLine
  If Selection.End >= ActiveDocument.Content.End - 1 Then
    Exit Do
  End If
  Set orng = ActiveDocument.Bookmarks("\Line").Range
  With orng
    .Collapse wdCollapseStart
    .MoveEnd wdCharacter, 1
    .Select
    ans = IsNumeric(orng)
    If orng.Font.Bold = False And ans = False Then
      Selection.HomeKey Unit:=wdLine
      Selection.TypeText Text:=vbTab
    End If
    'Do something with oRng
  End With
  Selection.MoveDown Unit:=wdLine
Loop
lbl_Exit:
Exit Sub
End Sub
I am using this code to insert tab for statements that are using more than 1 line.It is working well for first column but not for snaking column. I have to insert tab for all statements that are using more than 1 line.

Last edited by macropod; 07-06-2015 at 04:03 AM. Reason: Added code tags & formatting
Reply With Quote