Get text from clipboard to string?

G

Guest

Two questions:

How can I copy text from the clipboard to a string variable.

Where should I have looked to find this info?

Many thanks!
 
F

FSt1

hi
1. don't copy. just have the cell value = the string
dim stg as string
stg = Range("A1").value
2. here

Regards
FSt1
 
S

Susan

looking here is fine........
you don't have to copy it
==========================
dim myRange as range
dim s as string

set myRange = worksheet.range("a1")
s = myRange.value
==========================
then use s however you need to as a variable.
hope this helps
susan
 
R

Ron Rosenfeld

Two questions:

How can I copy text from the clipboard to a string variable.

Where should I have looked to find this info?

Many thanks!

I've not done this, but looking at VBA HELP for "clipboard", it seems to me
that I would rephrase your problem as being "How can I assign test to a string
variable". And the answer would then relate to the source of the text.

I think you have to put the information someplace before you can put it into a
string variable.

For example (given some data on the clipboard):

==========================
Option Explicit
Sub foo()
'get information from clipboard into string variable
Dim s As String
ActiveSheet.Paste Destination:=ActiveSheet.Range("a1")
s = [a1].Value
Debug.Print s
End Sub
===================

--ron
 
G

Guest

Thanks for your reply - See below

#2. Google is always nice.
Tried that but didn't find a good answer.
#1A. You could plop the value into an unused cell and then copy it from there
and clear the cell later.
Thought about that but that's sorta crude IF there is a better way
#1B. Chip Pearson's notes on working with the clipboard:
Page not found - Correct: http://www.cpearson.com/excel/clipboard.htm

Thanks - Chip's code worked!
 

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