Skip to main content

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

ParameterRequiredTypeDefaultDescription
objWordTrueexpressionobjWordWord document object
iMoveTrueexpression0Move the cursor from current position, starting from 0, and must be greater than or equal to 0
sTypeNoneenum"text"Object type to control. Options include: "Character", "Row", and "Paragraph". It defaults to "Character"
sPositionNoneenum"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
bShiftNonebooleanNoneWhether 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})