Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Excel 2010 Macro Changes?

Excel 2010 Macro Changes?

Excel 2010 Macro Changes?

Was wondering if the macro coding has changed in the 2010 version of Excel. We have a workbook with several macros in it. A few of these macros are for adding pictures to the workbook. The code in the macros works for Excel 2003 and 2007, but doesn't do as it should in 2010.

The problem we are having with 2010 is that it isn't really adding the actual picture to the workbook, but rather a link to the image. When the file is saved and sent via e-mail to others, the image is not there, but instead the following error message show where the image should:

"The linked image cannot be displayed. The file may have been moved, renamed or deleted. Verify that the link points to the correct file and location."

We need it to be able to save the picture within the file itself. Here is the code for the macro:


Sub InsertBigPicture()

Dim myPicture As String, MyObj As Object


myPicture = Application.GetOpenFilename _
    ("Pictures (*.gif; *.jpg; *.bmp; *.tif),*.gif; *.jpg; *.bmp; *.tif", _
        , "Select Picture to Import")

If myPicture = "False" Then Exit Sub

Set MyObj = ActiveSheet.Pictures.Insert(myPicture)

With MyObj
    With .ShapeRange
        .LockAspectRatio = msoTrue
        .Top = Range("H2").Top
        .Left = Range("H2").Left
        .Height = 160
        .Width = 215
        End With
    .Placement = xlMoveAndSize
End With

Set MyObj = Nothing

End Sub

Anyone have any ideas how to get this to save the picture and not just save a link to it?


RE: Excel 2010 Macro Changes?

You might want to try the AddPicture Method, where you can specify SaveWithDocument as True.


expression.AddPicture(Filename, LinkToFile, SaveWithDocument, Left, Top, Width, Height)

Check VBA Help

It might look like...


Set MyObj = ActiveSheet.Shapes.AddPicture( _
   myPicture, _
   False, _
   True, _
   Range("H2").Left, _
   Range("H2").Top, _
   215, _

With MyObj
    .ShapeRange.LockAspectRatio = msoTrue
    .Placement = xlMoveAndSize
End With


glassesJust traded in my old subtlety...
for a NUANCE!tongue

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close