简体   繁体   中英

Copy from clipboard and paste into a userform

I am using a program that populates a table with data, and the sizes (col/row) of these table grows every period in an unpredicted way.

So let's say I copy the contents of the table into clipboard, and what I want to know is:

Is it possible to paste this data into some sort of userform instead of going to an Excel sheet and then loading the source into a listbox?

I couldn't find any source material on this. I was interested to know if it was possible or if not, why it's not a good idea to do this!

I did find a lot of material about using the source of a table to populate a listbox, or, using a right click to copy data from a userform, but not the other way around.

This copyies any info in the current selection in clipboard and puts it into a textbox,

Dim clipBoard As MsForms.DataObject
Set clipBoard = New MsForms.DataObject

clipBoard.GetFromClipboard
TextBox1.Value = clipBoard.GetText(1)

Of course you can adapt this to have the data put into different form controls. You will need to handle when the clipboard is empty.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM