PDA

View Full Version : Solved: Sending Long to Clipboard or any other way to get it to Word from Excel?



itipu
08-18-2008, 02:36 PM
Hi all,

I have a Long which is just a big number I get through summing up values of a few ranges... so it is in memory. I would like to paste the value of this Long in a Word document which I already have opened and populated, so I have something like that:

Excel:


Dim pTotal As Long
pTotal = wsOne.Range("W33").Value + wsOne.Range("W35").Value

Word:

wrdApp.Selection.TypeText Text:="number"
wrdApp.Selection.TypeParagraph

All of these do work, I am just not sure how to send Long to clipboard, DataObject seems to work with String... I can than paste something like wrdApp.Selection.Paste...

Of course a quick hack would be to set some odd cell value to my pTotal and than do a Copy and Paste but surely there is a cleaner way?

Thanks a lot

Mike

malik641
08-18-2008, 04:52 PM
Why not just send pTotal? The runtime will convert it to a string for you, or you can cast it yourself:

[your range].Text = cStr(pTotal)

itipu
08-18-2008, 11:58 PM
I thought wrdApp.Selection.TypeText Text:=CStr(pTotal) was not possible, my mistake! Thanks for setting me straight!

Mike