PDA

View Full Version : PasteSpecial options



HTSCF Fareha
12-15-2020, 02:04 AM
I have been trying to find a resource that provides all the various PasteSpecial options without any success.

I'm particularly interested in finding out how to paste from Excel into Word (data already stored in clipboard) so that it will only paste in the actual values, any bold text, no cell border lines(?), maintain the column widths and not expand the data to fit across the whole width of the Word document.

For information the pasted data will be going into a RichText box Content Control object ("TextBox3").

A bit of a shopping list of requirements, but I hope that this is possible!

Thanks!



wdDoc.SelectContentControlsByTitle("TextBox3").Item(1).Range.PasteSpecial xlPasteColumnWidths

Dave
12-17-2020, 06:58 AM
I see that you're still at this. The only way to keep all the formatting U want is to take a picture of the range and paste it to the document. See... Range.CopyPicture method (Excel) | Microsoft Docs (https://docs.microsoft.com/en-us/office/vba/api/Excel.Range.CopyPicture) Not sure if it will paste to your content control oddly named textbox3?
Dave

HTSCF Fareha
12-17-2020, 07:07 AM
Thanks Dave, I see you've spotted the irony of the dreaded TextBox!! :)

I've since found that one can only have a single "special format", so have now been thinking about using something like the following.


Set wdDoc = wdApp.ActiveDocument
wdDoc.SelectContentControlsByTitle("TextBox3").Item(1).Range.PasteSpecial DataType:=wdPasteRTF
lbl_Exit:

I'm not in a position to try this for real yet due to not having access to the other database app, so am uncertain what result I will get.

Duly noted your suggestion!