Insert-Image
Command Description
Insert an image in the worksheet. If the specified image name already exists, replace the existing image
Command Prototype
Excel.InsertImage(objExcelWorkBook,sheet,sFilePath,sName,fLeft,fTop,fWidth,fHeight)
Parameter Description
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
objExcelWorkBook | True | expression | objExcelWorkBook | Excel workbook object (workbook opened with "Open Excel" command (Excel.OpenExcel) or the workbook object returned by the command "Bind Excel" (Excel.BindBook)) |
sheet | True | string | "Sheet1" | The string means sheet name. The number means sheet order(starting from 0) |
sFilePath | True | path | '''C:\Users''' | Path to the image file to insert |
sName | True | string | "" | Default value is empty string, which is automatically arranged by Excel. If you need to delete or update the corresponding picture, it is recommended to modify the name |
fLeft | True | expression | 0 | The margin to the left of the image |
fTop | True | expression | 0 | The margin to the top of the image |
fWidth | True | expression | 100 | The width of the image, calculated as percentage of the original image |
fHeight | True | expression | 100 | The height of the image, calculated as percentage of the original image |
Demo
/************************INSERT PICTURE************************ ********
**Input 1:
** objExcelWorkBook--Excel workbook object (a workbook opened using the "Open Excel" command (Excel.OpenExcel) or a job bound using the "Bind Excel" command (Excel.BindBook) book object).
**Entry 2:
** sheet--If a string is used, it means the name of the specified worksheet; if a number is used, it means the order of the specified worksheet (starting from 0).
**Entry 3:
** sFilePath--The path of the image file to be inserted.
**Entry 4:
** sName--The default value is an empty string, which is automatically arranged by Excel. If you want to delete or update the corresponding picture, it is recommended to modify the name.
**Entry 5:
** fLeft--The left margin of the image.
**Entry 6:
** fTop--The margin of the image from the top.
**Into reference 7:
** fWidth--the width of the image, calculated as a percentage of the original image.
** Entry 8:
** fHeight--The height of the image, calculated as a percentage of the original image.
**
*********************************************************************/
objExcelWorkBook = Excel.OpenExcel(@res"Test.xlsx",True,"Excel","","")
Excel.InsertImage(objExcelWorkBook,"Sheet1",@res"example image.png","example",0,0,100,100)
TracePrint "Insert a picture: Insert a picture named 'Example' in the Excel object Sheet1 worksheet
Excel.CloseExcel(objExcelWorkBook,True)