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 8534615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:14:10+00:00 2026-06-11T10:14:10+00:00

So I have a macro assigned to a command button. when pressed it opens

  • 0

So I have a macro assigned to a command button. when pressed it opens a dialogue box for user to import a picture file. Then it resizes the image and puts it on a specific cell.
But If I move the original picture file location, the image disappears in Excel. Is there any chance I can save it inside the excel file so that it will not matter if I move the original file location.

The code is as follow:

    Sub Add_Image()
    Application.ScreenUpdating = False
    Range("B18").Select
    'varible Picture1 is inserted down below - ***change both***
    Picture1 = Application.GetOpenFilename("Picture,*.JPG,Picture,*.JPEG,Picture,*.GIF,Picture,*.BMP")
    'edit "("Picture,*.*")" section to add or chanve visible file types
    On Error GoTo ErrMsg
    ActiveSheet.Pictures.Insert(Picture1).Select
    Selection.ShapeRange.LockAspectRatio = msoFalse
    Selection.ShapeRange.Height = 145
    Selection.ShapeRange.Width = 282
    Application.ScreenUpdating = True
    Exit Sub
ErrMsg:
    MsgBox ("Failed to load Image"), , "Error"
End Sub
  • 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-06-11T10:14:11+00:00Added an answer on June 11, 2026 at 10:14 am

    .Pictures.Insert doesn’t seem to provide control over linking or imbedding.

    However you can use this instead

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

    Sub Add_Image()
        Dim pic As Object
        Dim rng As Range
    
        Application.ScreenUpdating = False
        Set rng = Range("B18")
        Set rng2 = Range("A1", rng.Offset(-1, -1))
        'varible Picture1 is inserted down below - ***change both***
        Picture1 = Application.GetOpenFilename( _
            "Picture,*.JPG,Picture,*.JPEG,Picture,*.GIF,Picture,*.BMP")
        'edit "("Picture,*.*")" section to add or chanve visible file types
    
        On Error GoTo ErrMsg
        With Range("A1", rng.Offset(-1, -1))
            Set pic = ActiveSheet.Shapes.AddPicture(Picture1, False, True, _
                .Width, .Height, 282, 145)
        End With
        With pic
            .LockAspectRatio = msoFalse
        End With
        Application.ScreenUpdating = True
    Exit Sub
    ErrMsg:
        MsgBox ("Failed to load Image"), , "Error"
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a macro (Makro1) that is assigned to a button in a custom
I have assigned a macro to a button in worksheet 2. I have created
I have a macro setup to automatically open/save a file that I am opening
I have a macro that passes the line number and file name to an
I have a macro definition in header file like this: // header.h ARRAY_SZ(a) =
I am trying to have a macro, on command, find the last used cell
I have assigned macro to few buttons. How can I find out inside macro
I have a macro that creates a timestamp (to append to output file names).
I have this macro in my header file: #define UIColorFromRGB(rgbValue) \ [UIColor colorWithRed:((float)((rgbValue &
I have a macro that I would only like to be called at file

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.