copying cell text to non-Microsoft application

J

John C

Hi - i'm trying to copy the contents of a cell to the clipboard (so that I
can then paste it into a non-Microsoft program). When doing it manually,
selecting and copying the cell itself doesn't work - instead I need to 'go
into the cell' and select the text and copy it. How can I do this with VBA?

As an added twist, the cell contains a formula that concatenates text from a
number of other cells (to create a unique code). I actually need to copy
the result of the concatenation to the clipboard.

TIA, John
 
J

John C

Harald

Range("A1").Copy and Ctrl C don't work (I need to select and copy the text
inside the cell - from the formula bar), but the link to Chip Pearson's site
looks promising

tks john
 
G

Gord Dibben

John

If you copy the contents from the formula bar you will get the formula.

If you copy the cell you will get the concatenated result.

Which do you want? Seems you're asking for both.

Gord Dibben XL2002
 
J

John C

the link to Chip's site gave me what i needed; tks ...

Sub CopyTextToClipboard()
Dim DataObject As New DataObject

DataObject.SetText ActiveCell.Text
DataObject.PutInClipboard

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top