Question

I have an Excelfile with a picture in it.

Now I want to change the picture with VB. How do I do this? I tried it with

Dim anwendung As Excel.Application = New Excel.Application
Dim wbk As Excel.Workbook = anwendung.Workbooks.Open(Application.StartupPath + "\Ausgaben\Ausgabe.xls")


Dim wks As Excel.Worksheet = wbk.Worksheets("Kennzahlen")
wks.Shapes(1).Picture = LoadPicture(Application.StartupPath + "\Ausgaben\Leistungsdiagramm.tif")

But he doesnt know the LoadPicture-Method... Thx in advance!

Was it helpful?

Solution

Instead of picture object use a Shape object (Rectangular), and use this code:

 Sheets(1).Shapes(1).Fill.UserPicture ("e:\0\a\untitled.png")

beacause LoadPictuer load only BMP files.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top