P
Phil H
Using Excel 2003, this code was provided to me.
On sheet 3, an oval autoshape (one of many on the worksheet) has the below
code (macro) assigned to it.
Sub PasteRedSteady()
Dim shpTemp As Shape
Set shpTemp =
ActiveWorkbook.Worksheets("Graphics").Shapes("RedSteadyPaste")
PasteCenterOfRange shpTemp
Set shpTemp = Nothing
End Sub
The pasted oval autoshape is held in a worksheet named Graphics. The
example autoshape name is RedSteadyPaste. There are others with other names
too – each different autoshape having its own paste macro. Macros are
located in Module2.
When a user selects a cell or merged cell range, and clicks on an oval
autoshape(located on that same worksheet) with the macro assigned to it, a
duplicate oval autoshape, without code assigned to it, is pasted into the
center of the selected cell/cell range.
Sub PasteCenterOfRange(UseShape As Shape)
UseShape.Copy
ActiveSheet.Paste
With ActiveSheet.Shapes(ActiveSheet.Shapes.Count)
.Left = ActiveCell.MergeArea.Left + ((ActiveCell.MergeArea.Width -
..Width) / 2)
.Top = ActiveCell.MergeArea.Top + ((ActiveCell.MergeArea.Height -
..Height) / 2)
End With
ActiveCell.Select
End Sub
1.) To delete the pasted autoshape, it is highlighted and deleted. The
problem is deletion. If the user selects a cell with an autoshape already in
it and does not delete the existing autoshape, a new autoshape can be pasted
over it, thus, many autoshapes can be “stacked†in a cell. Is there a way to
delete the current autoshape(s), or clear the cell of any graphics, before
pasting a new one? This problem is graphics are bloating file size.
2.) Another question too. Is there a way to have all these above actions
duplicated in a linked cell/range on another worksheet? Whatever happens in
the Sheet3 cell/range happens exactly the same way in a Sheet1 cell/range.
Sheet3 is the source, Sheet1 is the target.
Any help would be greatly appreciated. Thanks, Phil.
On sheet 3, an oval autoshape (one of many on the worksheet) has the below
code (macro) assigned to it.
Sub PasteRedSteady()
Dim shpTemp As Shape
Set shpTemp =
ActiveWorkbook.Worksheets("Graphics").Shapes("RedSteadyPaste")
PasteCenterOfRange shpTemp
Set shpTemp = Nothing
End Sub
The pasted oval autoshape is held in a worksheet named Graphics. The
example autoshape name is RedSteadyPaste. There are others with other names
too – each different autoshape having its own paste macro. Macros are
located in Module2.
When a user selects a cell or merged cell range, and clicks on an oval
autoshape(located on that same worksheet) with the macro assigned to it, a
duplicate oval autoshape, without code assigned to it, is pasted into the
center of the selected cell/cell range.
Sub PasteCenterOfRange(UseShape As Shape)
UseShape.Copy
ActiveSheet.Paste
With ActiveSheet.Shapes(ActiveSheet.Shapes.Count)
.Left = ActiveCell.MergeArea.Left + ((ActiveCell.MergeArea.Width -
..Width) / 2)
.Top = ActiveCell.MergeArea.Top + ((ActiveCell.MergeArea.Height -
..Height) / 2)
End With
ActiveCell.Select
End Sub
1.) To delete the pasted autoshape, it is highlighted and deleted. The
problem is deletion. If the user selects a cell with an autoshape already in
it and does not delete the existing autoshape, a new autoshape can be pasted
over it, thus, many autoshapes can be “stacked†in a cell. Is there a way to
delete the current autoshape(s), or clear the cell of any graphics, before
pasting a new one? This problem is graphics are bloating file size.
2.) Another question too. Is there a way to have all these above actions
duplicated in a linked cell/range on another worksheet? Whatever happens in
the Sheet3 cell/range happens exactly the same way in a Sheet1 cell/range.
Sheet3 is the source, Sheet1 is the target.
Any help would be greatly appreciated. Thanks, Phil.