Need macro/VBA/Sub... that will paste data from the clip board into a single cell

D_Step

New Member
Joined
Nov 21, 2012
Messages
4
This macro/VAB/Sub... needs to be able to paste data into a single excel cell.
The copied data may be one word or multiple paragraphs from a word document.
Either way it needs to be pasted into one single cell.
The code needs to pick up from this point:


VBA Code:
' Paste info from clipboard starting at active cell

    ActiveCell.Select



I tried many different things that just does not work, from multiple variations of this code:

VBA Code:
Application.SendKeys ("{F2}{HOME}+{END}")



To multiple variations of this code:

VBA Code:
    ActiveCell.Select
    Selection.WrapText = True
    ActiveWorkbook.ActiveSheet.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:= _
        False, NoHTMLFormatting:=False



The problem with all of the things I tried is that it copies the data from the clipboard & pastes it into multiple cells, but I need the data to stay in one single cell.

I also real numerous threads here in which copying content from multiple Word documents to an Excel workbook is demonstrated and many more and none of them show how to do this. For example:
https://www.mrexcel.com/forum/gener...doc-files-into-excel-including-filenames.html
https://www.mrexcel.com/forum/gener...-multiple-word-doc-single-new-excel-file.html
https://www.mrexcel.com/forum/gener...068739-vba-excel-import-word-tables-help.html
https://www.mrexcel.com/forum/gener...cting-ms-word-form-data-into-excel-table.html
https://www.mrexcel.com/forum/gener...able-word-into-excel-based-table-headers.html
https://www.mrexcel.com/forum/gener...fic-range-remove-spaces-after-paragraphs.html
https://www.mrexcel.com/forum/gener...t-word-document-putting-them-excel-table.html


Thank you so much in advance!
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
It looks like you want to paste special, I don't know how to do that, but if it just to paste as text then try this:
Note: to work with clipboard you need to add the reference “Microsoft Forms 2.0 Object Library” (in VBE menu select Tool>References> select “Microsoft Forms 2.0 Object Library”)
VBA Code:
Sub pasteClipboard()

'you need to add the reference “Microsoft Forms 2.0 Object Library” (to work with clipboard)
Dim obj As New DataObject

obj.GetFromClipboard
ActiveCell = obj.GetText

End Sub
 
Upvote 0
Hello,

I have the exact same question. Basically I have multiple word docs in a folder which some are several pages long, and I would like to use a VBA script to copy each document entirely and paste the entire content of each document into a single excel.cell.

Basically if I were to have 30 documents in the folder I would end up with 30 rows of data. E.g. A1 thru A30.

Thank you very much for any help you can provide.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top