+ Reply to Thread
Results 1 to 6 of 6

Pasting OleObjects

  1. #1
    Forum Contributor
    Join Date
    08-02-2007
    Location
    Panama & Austria
    MS-Off Ver
    2003 & 2010
    Posts
    186

    Pasting OleObjects

    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:
    Please Login or Register  to view this content.
    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.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Pasting OleObjects

    Hello Wizz,

    This example macro copies only the OLE Objects from the source workbook to the destination workbook. As you can see, it is a bit more involved than copying Shapes.

    However, this will not copy any code associated with the OLE object, only the object class and the shape associated with it. If both sheets have the same column widths and row heights, the copied OLE objects will be positioned properly on the worksheet. If not, the objects will appear out of place.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    08-02-2007
    Location
    Panama & Austria
    MS-Off Ver
    2003 & 2010
    Posts
    186

    Re: Pasting OleObjects

    Thanks Ross,
    It worked great !

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Pasting OleObjects

    Since ActiveX-controls can contain VBA-code I'd prefer to copy the sheet, containing all these controls (copying the controls won't suffice in that case). The only thing to do then is adapt the layout and/or content of the cells in that copied worksheet.



  5. #5
    Forum Contributor
    Join Date
    08-02-2007
    Location
    Panama & Austria
    MS-Off Ver
    2003 & 2010
    Posts
    186

    Re: Pasting OleObjects

    Thanks snb and Leith for the hint about not copying any procedure.
    In my case it is even a benefit. The source sheet must not have any macros/procedures. I just needed to import everything for visual representation. Any code imported could cause trouble in my main sheet.

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Pasting OleObjects

    In that case:
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1