Solved

Excel VBA - Autoatically position an image when moved

Posted on 2014-03-10
2
279 Views
Last Modified: 2014-03-10
Hi
I was given the code below to add an image with its top left corner on a cell
and then more code to find the cell closest to the top left corner of an image.
Now I want to add code that runs when the image is moved that automatically
positions it so that its top and left borders are exactly aligned with the cell
closest to its top left cormer. I m guessing that I need to add a handler
that runs each time the image is moved


Sub A()
     With ThisWorkbook.Sheets("Sheet1").Pictures.Insert("C:\Users\Kevin Jones\Pictures\IM Avatars\zorvek.jpg")
        .ShapeRange.IncrementLeft ThisWorkbook.Sheets("Sheet1").Range("C3").Left
        .ShapeRange.IncrementTop ThisWorkbook.Sheets("Sheet1").Range("C3").Top
        .Name = "MyPicture"
    End With
End Sub
Sub B()
    For Each shp In ActiveSheet.Shapes
    MsgBox shp.TopLeftCell.Address
    Next
End Sub
0
Comment
Question by:murbro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 39917149
There aren't any events triggered by moving pictures on a sheet, I'm afraid. What's this for?
0
 

Author Closing Comment

by:murbro
ID: 39917161
Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question