Monitor clipboard......

A

Al

Hi Folks,

Does anyone know how to monitor the clipboard for data? Lets say for the
sake of an example its a string of format;

xxxxxxxxxxxx (where x = a 10 digit number)
name (where name = a given name)


Cheers

-Al
 
H

Helmut Weber

Hi Al,
the following puts text from the clipboard
into a variable, if that is would you are looking
for. To check, whether the variable contains a name
is impossible, in principle, as everything can be
a name. If you need help, checking whether the variable
starts with a 10 digit numeral, let us know.
Dim o As DataObject
Dim s As String
Set o = New DataObject
o.GetFromClipboard
s = o.GetText(1)
MsgBox s
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word XP, NT 4.0
 
A

Al

Thanks for the reply Helmut,

My situation is that I need to pass information between two programs that
simple cant be linked any other way.

I want the vba code to be constantly monitoring the clipboard for a 10 digit
number, and then it it detects a 10 digit number run another procedure.....

I might not have been clear in my first post...

-AL
 
H

Helmut Weber

Hi Al,
I would strongly advice you, not to try to use
VBA to constantly (!) monitor the clipboard.
I do in fact think, this can't be done at all
with justifiable effort. Though I understand
next to nothing from system programming, i'd say,
you would need something like an interrupt.
You may have a look at the clipboard every
x seconds using the ontime command. But there may
be unexpected complications.
Like this:
Public Sub WatchClpboard()
' call the appropriate procedure
' to look into the clipboard
Selection.TypeText Text:="---" & vbCr 'Test
Application.OnTime Now() + TimeValue
("00:00:04"), "WatchClpboard"
End Sub
Need a function to check for a 10 digit number, too?
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word XP, NT 4.0
 

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