ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error on paste (https://www.excelbanter.com/excel-programming/451644-error-paste.html)

Paul Doucette

Error on paste
 
This code has worked in the past for copying an oval shape with a clear background from one sheet to another. (we use it to circle info we wish to draw attention to). But it recently began to error at Activesheet.Paste. Any thoughts on why that might be? Or a way to fix, or do differently? Thanks in advance, Paul

Private Sub CommandButton2_Click()
Application.ScreenUpdating = False
Sheets("Sheet2").Select
ActiveSheet.Shapes("Oval 2").Select
Selection.Copy
Sheets("Sheet1").Select
ActiveSheet.unprotect
ActiveSheet.Paste
Selection.ShapeRange.IncrementLeft -12.75
Selection.ShapeRange.IncrementTop -30.25
Sheets("Sheet1").Select
ActiveCell.Offset(0, 4).Range("A1").Select
Sheets("Sheet1").Select
ActiveSheet.protect DrawingObjects:=False, Contents:=True, Scenarios:=True
Application.ScreenUpdating = True
End Sub

Claus Busch

Error on paste
 
Hi Paul,

Am Wed, 27 Jul 2016 10:59:29 -0700 (PDT) schrieb Paul Doucette:

This code has worked in the past for copying an oval shape with a clear background from one sheet to another. (we use it to circle info we wish to draw attention to). But it recently began to error at Activesheet.Paste. Any thoughts on why that might be? Or a way to fix, or do differently? Thanks in advance, Paul


try:
Private Sub CommandButton2_Click()
Application.ScreenUpdating = False

Sheets("Sheet2").Shapes("Oval 2").Copy

With Sheets("Sheet1")
.Unprotect
.Paste
With .Shapes("Oval 2")
.IncrementLeft -12.75
.IncrementTop -30.25
End With
.Protect DrawingObjects:=False, Contents:=True, Scenarios:=True
End With
Application.ScreenUpdating = True
End Sub


Regards
Claus B.
--
Windows10
Office 2016

Paul Doucette

Error on paste
 
On Wednesday, July 27, 2016 at 1:59:49 PM UTC-4, Paul Doucette wrote:
This code has worked in the past for copying an oval shape with a clear background from one sheet to another. (we use it to circle info we wish to draw attention to). But it recently began to error at Activesheet.Paste. Any thoughts on why that might be? Or a way to fix, or do differently? Thanks in advance, Paul

Private Sub CommandButton2_Click()
Application.ScreenUpdating = False
Sheets("Sheet2").Select
ActiveSheet.Shapes("Oval 2").Select
Selection.Copy
Sheets("Sheet1").Select
ActiveSheet.unprotect
ActiveSheet.Paste
Selection.ShapeRange.IncrementLeft -12.75
Selection.ShapeRange.IncrementTop -30.25
Sheets("Sheet1").Select
ActiveCell.Offset(0, 4).Range("A1").Select
Sheets("Sheet1").Select
ActiveSheet.protect DrawingObjects:=False, Contents:=True, Scenarios:=True
Application.ScreenUpdating = True
End Sub


Still hanging up at .Paste

Claus Busch

Error on paste
 
Hi Paul,

Am Wed, 27 Jul 2016 11:39:49 -0700 (PDT) schrieb Paul Doucette:

Still hanging up at .Paste


in my workbook it is working fine.
Try:

Private Sub CommandButton2_Click()
Application.ScreenUpdating = False

Sheets("Sheet2").Shapes("Oval 2").Copy
Sheets("Sheet1").Paste

With Sheets("Sheet1")
With .Shapes("Oval 2")
.IncrementLeft -12.75
.IncrementTop -30.25
End With
End With
Application.ScreenUpdating = True
End Sub


Regards
Claus B.
--
Windows10
Office 2016

Paul Doucette

Error on paste
 
On Wednesday, July 27, 2016 at 1:59:49 PM UTC-4, Paul Doucette wrote:
This code has worked in the past for copying an oval shape with a clear background from one sheet to another. (we use it to circle info we wish to draw attention to). But it recently began to error at Activesheet.Paste. Any thoughts on why that might be? Or a way to fix, or do differently? Thanks in advance, Paul

Private Sub CommandButton2_Click()
Application.ScreenUpdating = False
Sheets("Sheet2").Select
ActiveSheet.Shapes("Oval 2").Select
Selection.Copy
Sheets("Sheet1").Select
ActiveSheet.unprotect
ActiveSheet.Paste
Selection.ShapeRange.IncrementLeft -12.75
Selection.ShapeRange.IncrementTop -30.25
Sheets("Sheet1").Select
ActiveCell.Offset(0, 4).Range("A1").Select
Sheets("Sheet1").Select
ActiveSheet.protect DrawingObjects:=False, Contents:=True, Scenarios:=True
Application.ScreenUpdating = True
End Sub


Just tried on a different machine, and it works fine there too. I'm thinking my server needs a restart.
Sorry for bothering you, and thanks very much for pointing me in the right direction!
-Paul

GS[_6_]

Error on paste
 
This code has worked in the past for copying an oval shape with a
clear background from one sheet to another. (we use it to circle info
we wish to draw attention to). But it recently began to error at
Activesheet.Paste. Any thoughts on why that might be? Or a way to
fix, or do differently? Thanks in advance, Paul

Private Sub CommandButton2_Click()
Application.ScreenUpdating = False
Sheets("Sheet2").Select
ActiveSheet.Shapes("Oval 2").Select
Selection.Copy
Sheets("Sheet1").Select
ActiveSheet.unprotect
ActiveSheet.Paste
Selection.ShapeRange.IncrementLeft -12.75
Selection.ShapeRange.IncrementTop -30.25
Sheets("Sheet1").Select
ActiveCell.Offset(0, 4).Range("A1").Select
Sheets("Sheet1").Select
ActiveSheet.protect DrawingObjects:=False, Contents:=True,
Scenarios:=True Application.ScreenUpdating = True
End Sub


Why not just draw a new shape when/as needed?

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



All times are GMT +1. The time now is 09:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com