What is the appropriate code/command to paste a Form from the Excel ControlsToolBar?
I need to copy every OleObject and/or Shape from one workbook to another.
right now I'm using the following code:
Sub TransferSheetsDataFrom(SourceWb As Workbook, DestinyWb As Workbook, SheetName As String)
Dim SourceImageOrShape As Shape
Dim Posicion As String
Dim ActCell As Range
'On Both Worksheets the sheet name is the same.
'-----------------------------------------------------------------------
'Copy inside the DestinyWb the shapes present in SourceWb
'-----------------------------------------------------------------------
For Each SourceImageOrShape In SourceWb.Worksheets(SheetName).Shapes
Posicion = SourceImageOrShape.TopLeftCell.Address
SourceImageOrShape.Copy
DestinyWb.Worksheets(SheetName).Range(Posicion).PasteSpecial
'
Next SourceImageOrShape
'
It works wonderfully for shapes/pictures, but when there is an OleObject (I tested it with commandButtons,OptionButtons, from the Excel Objects toolbars) it pops Up an Error(if you proceed line by line with F8. If just press F5, the error msg wont popUp).
The error pops Up on the ".....PasteSpecial" line.
Bookmarks