Consulting

Results 1 to 3 of 3

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

  1. #1
    VBAX Contributor
    Joined
    Feb 2007
    Posts
    126
    Location

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

    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:

    [vba]
    Dim pTotal As Long
    pTotal = wsOne.Range("W33").Value + wsOne.Range("W35").Value[/vba]

    Word:

    [vba]wrdApp.Selection.TypeText Text:="number"
    wrdApp.Selection.TypeParagraph[/vba]

    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 [vba]wrdApp.Selection.Paste[/vba]...

    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

  2. #2
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    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)




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  3. #3
    VBAX Contributor
    Joined
    Feb 2007
    Posts
    126
    Location

    Yea you are right

    I thought [VBA]wrdApp.Selection.TypeText Text:=CStr(pTotal)[/VBA] was not possible, my mistake! Thanks for setting me straight!

    Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •