Move-Cursor-Position
Command Description
Move the cursor position in a Word document, relative to its current position
Command Prototype
Word.MovePosition(objWord,iMove,optionArgs)
Parameter Description
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
objWord | True | expression | objWord | Word document object |
iMove | True | expression | 0 | Move the cursor from current position, starting from 0, and must be greater than or equal to 0 |
sType | None | enum | "text" | Object type to control. Options include: "Character", "Row", and "Paragraph". It defaults to "Character" |
sPosition | None | enum | "right" | The direction in which the cursor is moved. Available options include "Right", "Left", "Down", and "Up". It defaults to "Right". The start position for "Left" and "Up" movements is the beginning of the selected text, and the start position for "Right" and "Down" movements is the end of the selected text |
bShift | None | boolean | None | Whether to press the shift key when moving the cursor. Default is "False", meaning not press |
Demo
/************************************Move cursor position************ ****************************
Command prototype:
Word.MovePosition(objWord,iMove,optionArgs)
Input parameters:
objWord--Word document object
iMove--The number of times the cursor is moved, starting from 1
sType--the object type of the operation
sPosition--cursor movement direction
bShift--Whether the shift key is held down when the cursor moves
*********************************************************************************/
Dim objWord
objWord = Word.Open('''C:\Users\Administrator\Desktop\Standardization Implementation Notes.docx''',"xw4131221","",true)
sRet = Word.ReadAll (objWord)
TracePrint ($ PrevResult)
Word.MovePosition(objWord,1,{"sType":"text","sPosition":"left","bShift":true})