+ Reply to Thread
Results 1 to 7 of 7

Pasting clipboard contents using VBA

  1. #1
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    583

    Pasting clipboard contents using VBA

    I have read Chip Pearson's information on how to use VBA to paste the contents of the clipboard into a sheet. He states that for this to work I must first "set a reference to the Microsoft Forms 2.0 Object Library.".

    Is this strictly to pull in code into the workbook I would be distributing or will any user of the workbook that I distribute it to also have to set a reference for it to work?

    I'd rather ask the dumb question than find out the hard way...

    Thank-you folks!

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Pasting clipboard contents using VBA

    The reference travels with the workbook.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Pasting clipboard contents using VBA

    Hi,

    There are 3 ways of accessing clipboard data that I know in VBA:
    a. Paste and PasteSpecial
    b. Early Binding - requires library reference
    c. Late Binding - does NOT require library reference

    For a discussion of the first two see: http://www.excelforum.com/excel-prog...ml#post4091725

    For an example using Early Binding and example using Late Binding see: https://desmondoshiwambo.wordpress.c...rosoft-access/
    NOTE: The 2nd example is using Microsoft Access

    Lewis

  4. #4
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    583

    Re: Pasting clipboard contents using VBA

    Again, many thanks-

    I will read all for though I thought I had found my answer, it wasn't quite. The area that is copied into the clipboard is basically a table, and when I use Ctrl-V to paste it into the worksheet, all is fine, but trying to simply copy the clipboard to a cell jams everything into that cell, and that isn't fine...

  5. #5
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Pasting clipboard contents using VBA

    Quote Originally Posted by shg View Post
    The reference travels with the workbook.
    I believe this is the case when using the same version of Excel. I believe the reference will come up missing if the destination computer is using Excel 2003, and the source computer is using a newer version of Excel.

    Lewis

  6. #6
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    583

    Re: Pasting clipboard contents using VBA

    Finding I could simply use "Paste" was an embarrassing surprise, but I am running into a bit of confusion - If I click on a cell then use
    Please Login or Register  to view this content.
    the entire table drops in perfectly, but if I use vba to select the proper cell as in
    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.
    It again crams everything into one cell.

    Any thoughts on how I should position the active cell some other way?

  7. #7
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    583

    Re: Pasting clipboard contents using VBA

    Not sure what I did different, but it works like it should now.

    Again, thank-you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Pasting range from clipboard
    By mattmania in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-04-2013, 09:20 AM
  2. How do I insert a column without pasting from the clipboard?
    By Dave42 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-26-2012, 06:06 AM
  3. Pasting date values from clipboard - help
    By tbilisi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-22-2008, 07:41 AM
  4. Clear sheet contents but retain Clipboard contents
    By nebb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-25-2007, 01:42 PM
  5. Replies: 0
    Last Post: 08-11-2006, 03:40 PM
  6. Pasting in code and clipboard message
    By KarenH in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-02-2006, 02:30 PM
  7. VBA Bloomberg, Clipboard Pasting Problem
    By Teiresias in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-19-2005, 06:32 AM
  8. Pasting from Excel Clipboard with VBA Macro
    By ExcelPeter218 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-09-2005, 11:06 PM

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