Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    Northampton, Northamptonshire, England
    Posts
    1,951
    Thanks
    2
    Thanked 1 Time in 1 Post

    Image changes name when pasted (Excel 2002/2003)

    Hi

    The attached Macro is to delete an inserted picture then select a new picture and paste that in the same place, however when it is insterted into the worksheet, picture 6 for instance becomes picture 104 or something like that . I have several pictures such as Picture 6, Picture 7, and so on so I would like to select the said Picture (Image). But I don't know what number the picture would be.

    ideally I would like to select and delete the Active.shape then go to the worksheet containg the pictures, select manually the new picture the macro would paste it into the worksheet.

    Many Thanks

    Braddy
    If you are a fool at forty, you will always be a fool

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Image changes name when pasted (Excel 2002/2003)

    Does this do what you want?
    <pre>Option Explicit
    Sub CopyShape()
    Dim vSel As Variant
    Dim rng As Range
    Dim rCopy As Range
    Dim shp As Shape
    Set vSel = Selection
    Set rCopy = Application.InputBox( _
    "Where do you want to copy?", Type:=8)
    With rCopy.Parent
    For Each shp In .Shapes
    Set rng = .Range(shp.TopLeftCell, shp.BottomRightCell)
    If Not Intersect(rCopy, rng) Is Nothing Then
    shp.Delete
    End If
    Next
    End With
    vSel.Copy
    rCopy.PasteSpecial
    Set rng = Nothing
    Set rCopy = Nothing
    Set shp = Nothing
    Set vSel = Nothing
    End Sub</pre>


    It asks for a range to copy, it deletes any shapes that have any part within the range then copies and pastes the selection into the range selected.

    Steve

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    Northampton, Northamptonshire, England
    Posts
    1,951
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Image changes name when pasted (Excel 2002/2003)

    Hi Steve

    That is excellent, thanks very much.

    Braddy
    If you are a fool at forty, you will always be a fool

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •