Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6245683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:32:58+00:00 2026-05-24T12:32:58+00:00

We’re exporting a set of data using .net interop to Excel and our template

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:32:58+00:00Added an answer on May 24, 2026 at 12:32 pm

    Are you sure Shape.Left won’t work? If done correctly, it works fine. Try it like this (C#):

    //This assumes shape is already assigned to the shape you want to move
    //and ws is assigned to the worksheet
    //set cell to whatever cell you want to move the image to
    Excel.Range cell = ws.Cells[10, 10];
    int pixels = 40; //Number of extra pixels over from the left edge of the cell
    shape.Left = ((float)cell.Left + pixels);
    shape.Top = ((float)cell.Top);
    

    To vb it should be something like below, but I’m not a vb expert

    Dim pixels As Integer = 40
    Dim cell As Excel.Range = ws.Cells(10, 10)
    s.Left = (CSng(cell.Left) + pixels) 'Note: if using cell.Left you must cast as single
    s.Top = CSng(cell.Top)
    

    Edit: I just created a test program in VB. The following code does, indeed, move my images.

        Dim oXL As Excel.Application
        Dim oWB As Excel.Workbook
        Dim oSheet As Excel.Worksheet
        Dim oRng As Excel.Range
        Dim oShape As Excel.Shape
    
        ' Start Excel and get Application object.
        oXL = CreateObject("Excel.Application")
        oXL.Visible = True
    
        ' Get a new workbook.
        oWB = oXL.Workbooks.Open("*insert_valid_path_here*")
        oSheet = oWB.ActiveSheet
        For Each oShape In oSheet.Shapes
            oShape.Left = oShape.Left + 9000
        Next
    
        ' Make sure Excel is visible and give the user control
        ' of Excel's lifetime.
        oXL.Visible = True
        oXL.UserControl = True
    
        ' Make sure that you release object references.
        oRng = Nothing
        oSheet = Nothing
        oWB = Nothing
        oXL.Quit()
        oXL = Nothing
    

    I suspect you are either assigning shape incorrectly or you expect it to be in the wrong spot or you are saving incorrectly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have just tried to save a simple *.rtf file with some websites and
We're building an app, our first using Rails 3, and we're having to build
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.