This article on the Octopus Brother-vb.net Office operation of Word (a) , based on the addition of the contents of the cursor operation, including getting the position of the cursor in the Word document, the cursor jumps to the specified line, move the cursor up or down the left and right actions. The method given in this article is copied directly to the class in the previous article. Don't know how to contact me. The next article will give this class specific implementation of the code, all the code is tested by the author, can be used directly.
' ********************************************************************* ' octopus brother, qq:3107073263 Group: 309816713 ' If you have any questions or good suggestions please contact me, everyone together progress ' ********************************************************************* ' Gets the current cursor position information, stored in the array public Function getcursor () as ArrayList Try Dim cursor as New ArrayList ' Current cursor page Dim page as Object = ZDocument.Application.Selection.Information (Word.WdInformation.wdActiveEndAdj Ustedpagenumber) ' Current cursor line number Dim row as Object = ZDocument.Application.Selection.Information (Word.wdin Formation.wdfirstcharacterlinenumber) ' current cursor is in the number of columns Dim cul as Object = ZDocument.Application.Selection. Information (Word.WdInformation.wdFirstCharacterColumnNumber) cursor. AddRange ({Page, row, cul}) Return cursor Catch ex as Exception MsgBox (ex. Message) Return Nothing end Try end Function ' mouse navigates to the specified page public Sub GoToPage (ByVal page asInteger) Try ' to jump to the specified page number ZDocument.Application.Selection.GoTo (Word.WdGoToItem.wdGoToPage, WORD.W Dgotodirection.wdgotofirst, Page) Catch ex as Exception MsgBox (ex. Message) End Try End Sub ' cursor is transferred to the specified line. This is the absolute jump public Sub gotoabsolutline (ByVal row as Integer) Try ' jump to the specified line, stating: This line is calculated relative to the entire document, will be like the first page on 2 lines, you jump to the third Line, is the 2nd page of the 1th line ' readers can test themselves, and currently does not implement a given page, row, column to the precise location of the function. At least I haven't realized it yet. There's no implementation here. ZDocument.Application.Selection.GoTo (Word.WdGoToItem.wdGoToLine, Word.WdGoToDirection.wdGoToFirst, Ro W) Catch ex as Exception MsgBox (ex. Message) End Try End Sub ' cursor is transferred to the specified line. This is relative jump. Everyone should understand what the meaning of the public Sub Gotooppsiteline (ByVal row as Int16) Try ' reader can self-test, currently also does not implement a given page, row, column to the precise location of the function. At least I haven't implemented if Row >= 0 Then ' if greater than 0, like after jump ZDocument.Application.Selection.GoTo (Word.WdGoToItem.wdG Otoline, Word.WdGoToDirection.wdGoToNext, Math.Abs (Row)) Else ' less than 0, like before jump ZDocument.Application.Selection.GoTo (Word.WdGoToItem.wdGoToLine, Word.WdGoToDirection.wdGoToPrevious, Math.Abs (R ow)) End If Catch ex as Exception MsgBox (ex. Message) End Try End Sub ' move left cursor public Sub MoveLeft () ZDocument.Application.Selection.MoveLeft () ' Each time Move 1-bit End Sub ' right-shift Public Sub MoveRight () ZDocument.Application.Selection.MoveRight () ' Move 1-bit End Sub each time ' Move Public Sub MoveUp () ZDocument.Application.Selection.MoveUp () ' Moves the 1-bit End sub ' down the Public sub Movedow N () ZDocument.Application.Selection.MoveDown () ' Moves 1-bit End Sub each time
Octopus Brother-vb.net Office operations Word (ii)