Inserting jpg image in Visio file using Python

Started by AhmedAl, July 24, 2019, 10:00:31 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

AhmedAl

Hello,

I recently started generating visio files using Python.
Right now, I'm stuck with this code (inserting jpg images into a shape):

Rect = objVdProc.Pages("PdG").DrawRectangle(1, Coord_y,1 , 1)
Rect.CellsSRC(visSectionObject, visRowXFormOut, visXFormPinX).FormulaU = Coord_x

Rect.CellsSRC(visSectionObject, visRowXFormOut, visXFormWidth).FormulaU = Largeur
Rect.CellsSRC(visSectionObject, visRowXFormOut, visXFormHeight).FormulaU = Hauteur

Rect.Cells("LineColor").FormulaU = "THEMEGUARD(RGB(255,255,255))"
filePath = "C:/Users/aallali/Documents/EDF rédaction de consignes/Logo_edf(1).jpg"
Rect.Import(filePath)

It gave me this error:
  File "C:/Users/aallali/Documents/EDF rédaction de consignes/Notebooks/Génération_Visio_1.0.1.py", line 2652, in <module>
    Rect.Import(filePath)

com_error: (-2147352567, 'An exception has occured.', (0, 'Dessin2 - Visio Professionnel', '\n\nObjet Inappropriate target for this operation.', None, 0, -2032465762), None)

Thanks