PC Review


Reply
Thread Tools Rate Thread

How to copy an image object to new location in shame sheet, Excel.

 
 
Asko Telinen
Guest
Posts: n/a
 
      15th Mar 2007

Hi all.

I have an image object inserted into sheet. What i need is to make a
copy of that image and move it to new location using VBA. I tried
Duplicate method defined in Shape object but that doesn´t work. Sure it
makes a copy of Shape object and everything goes smoothly (no errors
during duplicate) but image inside original shape object will not be
copied to new one!!! All i get is empty shape object and no picture!!!
Do i miss something or this is an bug?

Code:

' Create a duplicate from
Set CopyShape = sourceShape.Duplicate()

' Set new position
CopyShape.Left = sourceShape.Left
CopyShape.Top = startRow.Top + sourceShape.Top


Tried this code in both, excel 97 and 2003 pro, same result....
All servicepacks are installed.

OS: Windows XP Pro.


cheers....

Asko.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      15th Mar 2007
Sub AABB()
' Create a duplicate from
Set SourceShape = ActiveSheet.Shapes(1)
Set StartRow = SourceShape.TopLeftCell
Set CopyShape = SourceShape.Duplicate()

' Set new position
CopyShape.Left = SourceShape.Left
CopyShape.Top = StartRow.Top + SourceShape.Height

End Sub

put a copy of the shape right below the original for me. xl2003.

--
Regards,
Tom Ogilvy


"Asko Telinen" wrote:

>
> Hi all.
>
> I have an image object inserted into sheet. What i need is to make a
> copy of that image and move it to new location using VBA. I tried
> Duplicate method defined in Shape object but that doesn´t work. Sure it
> makes a copy of Shape object and everything goes smoothly (no errors
> during duplicate) but image inside original shape object will not be
> copied to new one!!! All i get is empty shape object and no picture!!!
> Do i miss something or this is an bug?
>
> Code:
>
> ' Create a duplicate from
> Set CopyShape = sourceShape.Duplicate()
>
> ' Set new position
> CopyShape.Left = sourceShape.Left
> CopyShape.Top = startRow.Top + sourceShape.Top
>
>
> Tried this code in both, excel 97 and 2003 pro, same result....
> All servicepacks are installed.
>
> OS: Windows XP Pro.
>
>
> cheers....
>
> Asko.
>

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      15th Mar 2007
One other thought. When you are playing with shapes, you can often get many
shapes on the sheet you are not aware of. Make sure the SourceShape
actually refers to the shape you are trying to copy.

sub CountShapes()
msgbox "there are " & Activesheet.shapes.count & _
" Shapes on the sheet"
End sub

--
regards,
Tom Ogilvy


"Asko Telinen" wrote:

>
> Hi all.
>
> I have an image object inserted into sheet. What i need is to make a
> copy of that image and move it to new location using VBA. I tried
> Duplicate method defined in Shape object but that doesn´t work. Sure it
> makes a copy of Shape object and everything goes smoothly (no errors
> during duplicate) but image inside original shape object will not be
> copied to new one!!! All i get is empty shape object and no picture!!!
> Do i miss something or this is an bug?
>
> Code:
>
> ' Create a duplicate from
> Set CopyShape = sourceShape.Duplicate()
>
> ' Set new position
> CopyShape.Left = sourceShape.Left
> CopyShape.Top = startRow.Top + sourceShape.Top
>
>
> Tried this code in both, excel 97 and 2003 pro, same result....
> All servicepacks are installed.
>
> OS: Windows XP Pro.
>
>
> cheers....
>
> Asko.
>

 
Reply With Quote
 
Asko Telinen
Guest
Posts: n/a
 
      18th Mar 2007
Tom Ogilvy wrote:
> One other thought. When you are playing with shapes, you can often get many
> shapes on the sheet you are not aware of. Make sure the SourceShape
> actually refers to the shape you are trying to copy.
>
> sub CountShapes()
> msgbox "there are " & Activesheet.shapes.count & _
> " Shapes on the sheet"
> End sub
>


Thanks for your reply. And you were right
There WAS an empty image right behind the image i wanted to copy
and the code took that image Silly me.
Seems like to every problem is simple answer.

Thanks again.

Asko.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SHAME SHAME SHAME ON THOSE POOR VENTILATED SLI RIGS. Skybuck Flying DIY PC 8 17th Aug 2008 01:04 PM
Protect excel sheet and still copy text or object w/o unprotectin. =?Utf-8?B?U2FpbnQ=?= Microsoft Excel Misc 2 29th May 2006 12:44 AM
Using VB.Net or C#, utilizing the clipboard object, how to copy an MS Excel graphic from the clipboard to an image control and obtain its source reference TC Microsoft Dot NET 5 1st Sep 2004 05:49 AM
Using VB.Net or C#, utilizing the clipboard object, how to copy an MS Excel graphic from the clipboard to an image control and obtain its source reference TC Microsoft C# .NET 2 27th Jul 2004 06:07 PM
Using VB.Net or C#, utilizing the clipboard object, how to copy an MS Excel graphic from the clipboard to an image control and obtain its source reference TC Microsoft VB .NET 2 27th Jul 2004 06:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:22 AM.