Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Copy/Paste Picture Fails - then works

Hi,

My code:
Sub AddPhotoPictureWithNAme()

' This Macro creates a picture element from the contents of a range, and names it

Dim Pct As Picture, Rng As Range, Shp as Shape

' Identify and copy the source
Set Rng = Range("B2:C6")
Rng.Copy

'
Set Pct = ActiveSheet.Pictures.Add(100, 100, 100, 100)
Pct.Name = "Project Clip"

For Each Shp In ActiveSheet.Shapes
Debug.Print Shp.Name
Next Shp

End Sub

.... runs till it gets to the 'Set Pct =' step then flops into debug, upon which I can then proceed without an error. I thought it might be a timing issue, but I'm not sure. Can anyone help?

Greg
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Copy/Paste Picture Fails - then works

Hi Greg,

Am Thu, 20 Jun 2013 21:59:42 -0700 (PDT) schrieb Greg Glynn:

... runs till it gets to the 'Set Pct =' step then flops into debug, upon which I can then proceed without an error. I thought it might be a timing issue, but I'm not sure. Can anyone help?


for me it works fine.
But you can also try:

Sub AddPhotoPictureWithName()

' This Macro creates a picture element from the contents of a range,
and names it
Dim Pct As Picture, Rng As Range, Shp As Shape

' Identify and copy the source
With ActiveSheet
Set Rng = .Range("B2:C6")
Rng.CopyPicture xlScreen, xlBitmap
.Paste Destination:=.Range("A1")
End With
With Selection
.Name = "Project Clip"
.Top = 100
.Left = 100
End With
End Sub


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Copy/Paste Picture Fails - then works

Thanks Claus - I found the bug. I changed the

Set Rng = Range("A2:AK14")
to
Set Rng = ActiveSheet.Range("A2:AK14")

(it was crapping out when running from the Editor - No focus?)

Thanks for your code. I'll check it out right away.

Greg
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy/Paste in VBA fails? Maury Markowitz[_2_] Excel Programming 2 September 10th 08 06:36 PM
Why Copy/Paste fails using Offset & Resize of myRange? [email protected] Excel Discussion (Misc queries) 3 November 21st 06 02:06 AM
Copy paste code fails Ron Dean[_2_] Excel Programming 0 January 17th 06 11:49 AM
Filter Copy/Paste Fails - Two Ranges Selected? Craigm[_27_] Excel Programming 4 July 15th 05 04:16 PM
I cannot paste from one workbook to another. Copy works, paste do. JimmyMc Excel Discussion (Misc queries) 1 June 10th 05 03:54 PM


All times are GMT +1. The time now is 10:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"