On focus - check clipboard

A

Al Grant

Hi guys,

I want a dialog box to check for data that fits a specific format when it
gets focus (after the user returns to word from another application.

It does not have to constantly monitor for this data - only after a user
returns to word. Any idea how to do this?

Cheers

-Al
 
P

Peter Hewett

Hi Al Grant

When you say a <dialog box> do you mean one of Words built in dialogs or a UserForm. If
it's a Word dialog then I think it's virtually impossible. If you mean a UserForm it may
be possible using Windows API calls but not from VBA.

HTH + Cheers - Peter
 
J

Jezebel

You can use the WindowActivate event to detect the return to Word from
another application, if the other application can itself be activated (won't
work, I think, if the other application is entirely invisible). This event
is fired also by some actions within Word -- eg if you switch between
multiple windows -- but presumably it doesn't matter for your purposes if
the check is run too often.
 
P

Peter Hewett

Hi Jezebel

That's what the documentation says and that's what I thought until I tried it (Win 2k SP4,
Office XP SP3) when I Alt+Tab back to the UserForm (from another application) the event
does not fire! Other than when I launch (or should that be lunch!) the Form I can't get
the UserForm_Activate event to fire.

When I get a moment I'll try 2003.

Can you let me know if it works for you.

Cheers - Peter


You can use the WindowActivate event to detect the return to Word from
another application, if the other application can itself be activated (won't
work, I think, if the other application is entirely invisible). This event
is fired also by some actions within Word -- eg if you switch between
multiple windows -- but presumably it doesn't matter for your purposes if
the check is run too often.

HTH + Cheers - Peter
 
H

Helmut Weber

Hi Al,
I don't know how to trigger an event when a user
has switched back to word from another application.
Perhaps you mean just something like this,
in case you are talking about a userform:
Private Sub TextBox1_Enter()
Dim oDat As DataObject
Dim s As String
Set oDat = New DataObject
oDat.GetFromClipboard
s = oDat.GetText
MsgBox s
End Sub
---
You could check from the form which control
has the focus, like
if Me.ActiveControl.Name = "Textbox1"
---
HTH
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 
A

Al Grant

yes - I mean a userform that is created in VBA.

Will do some experiments with UserForm_Activate......

The data looks something like:

(Real) SMTH Michael John....................(ID)123456
789..............(Address) 123 Any Street, Mt Eden, Auckland, 1705

And I need to extract each of these items out, such as First names, family
names
street, town, suburb, ID number etc.

The dots represent some weird character, which I aint ID'd yet.

Cheers

-Al
 
A

Al Grant

I also want this to be able to run on NT4 which I think creates issues with
WindowActivate.

Damn, perhaps I am trying to do things the hardway.

Perhaps I should just make users double click the window or add a button to
get the
data from the clipboard to populate the userform?!?!?!?!

-Al
 
H

Helmut Weber

hi Al,
Perhaps I should just make users double click the window
or add a button to get the data from the clipboard
That is what I would do. Sometimes the only thing
perfect automation does, is decreasing concentration
of users. By the way, looking at your example of data,
the worst (parsing them) is yet to come.
 
A

Al Grant

parsing : I assume that means seperating??

-Al

Helmut Weber said:
hi Al,
That is what I would do. Sometimes the only thing
perfect automation does, is decreasing concentration
of users. By the way, looking at your example of data,
the worst (parsing them) is yet to come.
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 
H

Helmut Weber

Hi Al,
"to parse" was the verb we used long time ago at university,
for analyzing the structure of a text, sentence, phrase or word,
or other related structure, like icons as opposed to symbols.
Which may rise another question. ;-)
Seperating would be the next step, using the results of parsing,
I guess. But I am not a native speaker of English. Always trying
to learn and never arriving at where I would like to be.
 
A

Al Grant

so anybody got any ideas on the parsing?

I guess i need to get it off the clipboard before parsing?

-Al
 

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