We’re exporting a set of data using .net interop to Excel and our template file contains some images.
Depending on the amount of columns we’re exporting we want to position the image X pixels left of the last column depending on the image size/width. Using the record a macro function moving the Image around is a ‘no op’. Setting the Shape.Left position also won’t work.
The question
How do you position an image in excel using interop X pixels left from a cell or in a fixed X/Y position on screen where X/Y are pixel locations relative to a cell.
This did not work
Dim pixels As Integer = 40
Dim cell As Excel.Range = ws.Cells(10, 10)
s.Left = s.Left - 100
The ‘solution’
After debugging for a while we noticed that this did not work on my office version. Updating my office version to 2010 made the above example work again. We added another PictureShape to replace for office 2007 fixing our own problems.
Are you sure Shape.Left won’t work? If done correctly, it works fine. Try it like this (C#):
To vb it should be something like below, but I’m not a vb expert
Edit: I just created a test program in VB. The following code does, indeed, move my images.
I suspect you are either assigning shape incorrectly or you expect it to be in the wrong spot or you are saving incorrectly.