Solved

Excel VBA - Autoatically position an image when moved

Posted on 2014-03-10
2
270 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
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now