Skip to main content

Set-Cursor-Position

Command Description

Set the cursor position in a word document

Command Prototype

Word.SetPosition(objWord,iMove,optionArgs)

Parameter Description

ParameterRequiredTypeDefaultDescription
objWordTrueexpressionobjWordWord document object
iMoveTruenumber1The number of cursor movements (≥1)
sTypeNoneenum"text"Object type to control. Options include: "Character", "Row", and "Paragraph". It defaults to "Character"

Demo

/************************************Set cursor position************ **************************** 
Command prototype:
Word.SetPosition(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
*********************************************************************************/
Dim objWord
objWord = Word.Open('''C:\Users\Administrator\Desktop\Standardization Implementation Notes.docx''',"xw4131221","",true)
sRet = Word.ReadAll (objWord)
TracePrint ($ PrevResult)
Word.SetPosition(objWord,4,{"sType":"section"})