Skip to main content

Insert-Image

Command Description

Insert an image at the current cursor position in a Word document

Command Prototype

Word.InsertPicture(objWord,sPath,optionArgs)

Parameter Description

ParameterRequiredTypeDefaultDescription
objWordTrueexpressionobjWordWord document object
sPathTruepath'''C:\Users'''Path of the image file
linkToFileNonebooleanTrueWhether to copy the inserted image (the default is yes)
saveWithDocumentNonebooleanTrueWhether to save the inserted image into the Word document (the default is yes)

Demo

/************************************Insert picture************** ************************ 
Command prototype:
Word.InsertPicture(objWord,sPath,optionArgs)
Input parameters:
objWord--Word document object
sPath--image file path
linkToFile--Whether to copy the inserted picture
saveWithDocument - whether to save the inserted picture to the Word document
*********************************************************************************/
Dim objWord
objWord = Word.Open('''C:\Users\Administrator\Desktop\Standardization Implementation Notes.docx''',"xw4131221","",true)
Word.SelectRow(objWord,3,3)
Word.InsertPicture(objWord,'''C:\Users\Administrator\Pictures\Camera Roll\001.jpg''',{"linkToFile":true,"saveWithDocument":true})