Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Get the value of selected text (outside of Excel)?

Fellow programmers,

This one is driving me up a wall... Is it possible to get the value
of selected text on another program as the value of a textbox on a
userform? If so, how is this done? I've looked into the some API code
for GetWindowText and WM_GETTEXT but I have been very unsuccessful
very quickly. Any thoughts? I appreciate any feed back available.

Thank you in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Get the value of selected text (outside of Excel)?

That is a good questionn and I am going to say yes; as long as the value is
assigned to variable; in this case, a string variable.
I pass code between AutoCAD and Excel with no problem, so it the code can
get to the other app, then I'm sure it can be read by a textbox in the
receiving app.
I have read lines of text from a .txt file into a list box in ACAD, so that
certainly can be done.

Can you be a little more specific as to what you are trying to do?
Besides Excel, what is the other app?

ML


" wrote:

Fellow programmers,

This one is driving me up a wall... Is it possible to get the value
of selected text on another program as the value of a textbox on a
userform? If so, how is this done? I've looked into the some API code
for GetWindowText and WM_GETTEXT but I have been very unsuccessful
very quickly. Any thoughts? I appreciate any feed back available.

Thank you in advance!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Get the value of selected text (outside of Excel)?

On Jul 20, 7:11*pm, ML0940 wrote:
That is a good questionn and I am going to say yes; as long as the value is
assigned to variable; in this case, a string variable.
I pass code between AutoCAD and Excel with no problem, so it the code can
get to the other app, then I'm sure it can be read by a textbox in the
receiving app.
I have read lines of text from a .txt file into a list box in ACAD, so that
certainly can be done.

Can you be a little more specific as to what you are trying to do?
Besides Excel, what is the other app?

ML



" wrote:
Fellow programmers,


* *This one is driving me up a wall... Is it possible to get the value
of selected text on another program as the value of a textbox on a
userform? If so, how is this done? I've looked into the some API code
for GetWindowText and WM_GETTEXT but I have been very unsuccessful
very quickly. Any thoughts? I appreciate any feed back available.


Thank you in advance!- Hide quoted text -


- Show quoted text -


Say I was working inside of internet explorer and I wanted to
essentially have selected text using the mouse appear as a value in a
textbox on a userform... now before anyone suggests having CTRL + C
and CTRL + V as a result -- I am not looking to go down that avenue as
it doesn't work... I've tried using the Windows API to select text
based on mouse cordinates (x, z) and using the sendkeys commands to
copy the value of the selected text and try to paste in a textbox on a
userform... it doesn't work. Someone can try the very same code if
they would like...


Private Sub Commandbutton1_Click()
SetCursorPos 255, 413

DoEvents
Application.Run "mouscoords"
'------------------ mosecoords grabs the current mouse cordinates

mouse_event MOUSEEVENTF_LEFTDOWN, 0&, 0&, 0&, 0&
'------------------ API to press the left mouse button on those cords

Do Until UserForm1.TextBox1.Value = 520
'------------------ Have the macro stop when the x value = 520

UserForm1.TextBox1.Value = UserForm1.TextBox1.Value + 5
'------------------ Figure the average character size (font size 10)
is going to be 5 pixels wide

SetCursorPos UserForm1.TextBox1.Value, 413
'------------------- Textbox1.value is the X cordinate +5 the old one

DoEvents
'------------------ Update the textboxes and continue running until
end IF statement works
Loop

mouse_event MOUSEEVENTF_LEFTUP, 0&, 0&, 0&, 0&
'------------------ Release the mouse button

Application.Wait Now +TimeValue("00:00:01")
'------------------- Wait for the system to refresh

SendKeys "^C", True
'------------------- Copy the selected text value

Application.Wait Now +TimeValue("00:00:01")
'------------------- Wait for the system to refresh

Userform1.Textbox3.SetFocus
'------------------- Set focus to the textbox I want the value to put
into

SendKeys "^V", True
'------------------- Paste the selected text value

For whatever reason the code doesn't work... So I am hoping to venture
down the road of being able to have the system say "the selected text
is the following value..." in a textbox on a userform.

Any help is greatly appreciated!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Get the value of selected text (outside of Excel)?

Oh God
I think you are asking if you copy text from any place, such as a web page?
It is an interesting idea, only I am not sure it is possible.
I think there is a technique called crawling but I am not familiar with it.
I thought that you were looking for something very specific, such as a
variable that you wanted to pass to another app.

I would only use Sendkeys if there is no other way as well but looking at
your code, it doesn't look like you did Ctrl C and Ctrl V correctly.

I have tried it but this is from The Excel-VBA help screen:

ML

To specify keys combined with any combination of the SHIFT, CTRL, and ALT
keys, precede the key code with one or more of the following codes:
Key Code
SHIFT +
CTRL ^
ALT %


" wrote:

On Jul 20, 7:11 pm, ML0940 wrote:
That is a good questionn and I am going to say yes; as long as the value is
assigned to variable; in this case, a string variable.
I pass code between AutoCAD and Excel with no problem, so it the code can
get to the other app, then I'm sure it can be read by a textbox in the
receiving app.
I have read lines of text from a .txt file into a list box in ACAD, so that
certainly can be done.

Can you be a little more specific as to what you are trying to do?
Besides Excel, what is the other app?

ML



" wrote:
Fellow programmers,


This one is driving me up a wall... Is it possible to get the value
of selected text on another program as the value of a textbox on a
userform? If so, how is this done? I've looked into the some API code
for GetWindowText and WM_GETTEXT but I have been very unsuccessful
very quickly. Any thoughts? I appreciate any feed back available.


Thank you in advance!- Hide quoted text -


- Show quoted text -


Say I was working inside of internet explorer and I wanted to
essentially have selected text using the mouse appear as a value in a
textbox on a userform... now before anyone suggests having CTRL + C
and CTRL + V as a result -- I am not looking to go down that avenue as
it doesn't work... I've tried using the Windows API to select text
based on mouse cordinates (x, z) and using the sendkeys commands to
copy the value of the selected text and try to paste in a textbox on a
userform... it doesn't work. Someone can try the very same code if
they would like...


Private Sub Commandbutton1_Click()
SetCursorPos 255, 413

DoEvents
Application.Run "mouscoords"
'------------------ mosecoords grabs the current mouse cordinates

mouse_event MOUSEEVENTF_LEFTDOWN, 0&, 0&, 0&, 0&
'------------------ API to press the left mouse button on those cords

Do Until UserForm1.TextBox1.Value = 520
'------------------ Have the macro stop when the x value = 520

UserForm1.TextBox1.Value = UserForm1.TextBox1.Value + 5
'------------------ Figure the average character size (font size 10)
is going to be 5 pixels wide

SetCursorPos UserForm1.TextBox1.Value, 413
'------------------- Textbox1.value is the X cordinate +5 the old one

DoEvents
'------------------ Update the textboxes and continue running until
end IF statement works
Loop

mouse_event MOUSEEVENTF_LEFTUP, 0&, 0&, 0&, 0&
'------------------ Release the mouse button

Application.Wait Now +TimeValue("00:00:01")
'------------------- Wait for the system to refresh

SendKeys "^C", True
'------------------- Copy the selected text value

Application.Wait Now +TimeValue("00:00:01")
'------------------- Wait for the system to refresh

Userform1.Textbox3.SetFocus
'------------------- Set focus to the textbox I want the value to put
into

SendKeys "^V", True
'------------------- Paste the selected text value

For whatever reason the code doesn't work... So I am hoping to venture
down the road of being able to have the system say "the selected text
is the following value..." in a textbox on a userform.

Any help is greatly appreciated!




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Get the value of selected text (outside of Excel)?

On Jul 20, 8:16*pm, ML0940 wrote:
Oh God
I think you are asking if you copy text from any place, such as a web page?
It is an interesting idea, only I am not sure it is possible.
I think there is a technique called crawling but I am not familiar with it.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Get the value of selected text (outside of Excel)?

I may be willing to dive in with you an try to figure it out
I also do VBScripting and there are alot of great methods with it that are
more intrinsic to Windows as opposed to the particular app, as with VBA.

So tell me, what does WM_GETTEXT stand for?
Is that Windows Management?

I have a feeling that crawling techniques are what is used by hackers and
such to get passwords etc.; I'm not sure though, as I am not a hacker.
Well, I hack my own code but that is about it :)

So, tell me the definition and where did you get started?
Was it a Google Search?

ML



" wrote:

On Jul 20, 8:16 pm, ML0940 wrote:
Oh God
I think you are asking if you copy text from any place, such as a web page?
It is an interesting idea, only I am not sure it is possible.
I think there is a technique called crawling but I am not familiar with it.
I thought that you were looking for something very specific, such as a
variable that you wanted to pass to another app.

I would only use Sendkeys if there is no other way as well but looking at
your code, it doesn't look like you did Ctrl C and Ctrl V correctly.

I have tried it but this is from The Excel-VBA help screen:

ML

To specify keys combined with any combination of the SHIFT, CTRL, and ALT
keys, precede the key code with one or more of the following codes:
Key Code
SHIFT +
CTRL ^
ALT %



" wrote:
On Jul 20, 7:11 pm, ML0940 wrote:
That is a good questionn and I am going to say yes; as long as the value is
assigned to variable; in this case, a string variable.
I pass code between AutoCAD and Excel with no problem, so it the code can
get to the other app, then I'm sure it can be read by a textbox in the
receiving app.
I have read lines of text from a .txt file into a list box in ACAD, so that
certainly can be done.


Can you be a little more specific as to what you are trying to do?
Besides Excel, what is the other app?


ML


" wrote:
Fellow programmers,


This one is driving me up a wall... Is it possible to get the value
of selected text on another program as the value of a textbox on a
userform? If so, how is this done? I've looked into the some API code
for GetWindowText and WM_GETTEXT but I have been very unsuccessful
very quickly. Any thoughts? I appreciate any feed back available.


Thank you in advance!- Hide quoted text -


- Show quoted text -


Say I was working inside of internet explorer and I wanted to
essentially have selected text using the mouse appear as a value in a
textbox on a userform... now before anyone suggests having CTRL + C
and CTRL + V as a result -- I am not looking to go down that avenue as
it doesn't work... I've tried using the Windows API to select text
based on mouse cordinates (x, z) and using the sendkeys commands to
copy the value of the selected text and try to paste in a textbox on a
userform... it doesn't work. Someone can try the very same code if
they would like...


Private Sub Commandbutton1_Click()
SetCursorPos 255, 413


DoEvents
Application.Run "mouscoords"
'------------------ mosecoords grabs the current mouse cordinates


mouse_event MOUSEEVENTF_LEFTDOWN, 0&, 0&, 0&, 0&
'------------------ API to press the left mouse button on those cords


Do Until UserForm1.TextBox1.Value = 520
'------------------ Have the macro stop when the x value = 520


UserForm1.TextBox1.Value = UserForm1.TextBox1.Value + 5
'------------------ Figure the average character size (font size 10)
is going to be 5 pixels wide


SetCursorPos UserForm1.TextBox1.Value, 413
'------------------- Textbox1.value is the X cordinate +5 the old one


DoEvents
'------------------ Update the textboxes and continue running until
end IF statement works
Loop


mouse_event MOUSEEVENTF_LEFTUP, 0&, 0&, 0&, 0&
'------------------ Release the mouse button


Application.Wait Now +TimeValue("00:00:01")
'------------------- Wait for the system to refresh


SendKeys "^C", True
'------------------- Copy the selected text value


Application.Wait Now +TimeValue("00:00:01")
'------------------- Wait for the system to refresh


Userform1.Textbox3.SetFocus
'------------------- Set focus to the textbox I want the value to put
into


SendKeys "^V", True
'------------------- Paste the selected text value


For whatever reason the code doesn't work... So I am hoping to venture
down the road of being able to have the system say "the selected text
is the following value..." in a textbox on a userform.


Any help is greatly appreciated!- Hide quoted text -


- Show quoted text -


Well thanks for trying... it's a shame that there isn't a straight
foward approach to using WM_GETTEXT...

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Get the value of selected text (outside of Excel)?


OK
I did a Google search.
This link is stright from Microsoft's Web Page
While it is an interesting concept, you are correct, it doesn't look very
stright forward or well explained.
ML

http://msdn.microsoft.com/en-us/library/aa922085.aspx

" wrote:

Fellow programmers,

This one is driving me up a wall... Is it possible to get the value
of selected text on another program as the value of a textbox on a
userform? If so, how is this done? I've looked into the some API code
for GetWindowText and WM_GETTEXT but I have been very unsuccessful
very quickly. Any thoughts? I appreciate any feed back available.

Thank you in advance!

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Get the value of selected text (outside of Excel)?

On Jul 20, 9:16*pm, ML0940 wrote:
OK
I did a Google search.
This link is stright from Microsoft's Web Page
While it is an interesting concept, you are correct, it doesn't look very
stright forward or well explained.
ML

http://msdn.microsoft.com/en-us/library/aa922085.aspx



" wrote:
Fellow programmers,


* *This one is driving me up a wall... Is it possible to get the value
of selected text on another program as the value of a textbox on a
userform? If so, how is this done? I've looked into the some API code
for GetWindowText and WM_GETTEXT but I have been very unsuccessful
very quickly. Any thoughts? I appreciate any feed back available.


Thank you in advance!- Hide quoted text -


- Show quoted text -


It's the oddest thing... there is no specific "Starters Guide to
WM_GETTEXT or WM_SENDTEXT... I feel like I did when to a Roman
Catholic wedding (not trying to offend anyone, as I am Christian) --
but that feeling is I'm familar with what's going on but generally
lost with how to do the 'traditions'.

I almost want to start a thread called "WM_GETTEXT / WM_SENDTEXT for
Newbies/Dummies". I found some app that allows me to view the Control
ID (which I assume is the same as me saying UserForm1.Textbox1.Value)
but still there is no answer as to how to use this code or how to
implement it to do something like send the value of textbox1.value to
Control ID titled "text1".

What's amazing is something that is useful as this isn't explained
very well... it's going to be a whole new world if this is explained
by some genious.
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Get the value of selected text (outside of Excel)?

On Jul 20, 10:09*pm, wrote:
On Jul 20, 9:16*pm, ML0940 wrote:





OK
I did a Google search.
This link is stright from Microsoft's Web Page
While it is an interesting concept, you are correct, it doesn't look very
stright forward or well explained.
ML


http://msdn.microsoft.com/en-us/library/aa922085.aspx


" wrote:
Fellow programmers,


* *This one is driving me up a wall... Is it possible to get the value
of selected text on another program as the value of a textbox on a
userform? If so, how is this done? I've looked into the some API code
for GetWindowText and WM_GETTEXT but I have been very unsuccessful
very quickly. Any thoughts? I appreciate any feed back available.


Thank you in advance!- Hide quoted text -


- Show quoted text -


It's the oddest thing... there is no specific "Starters Guide to
WM_GETTEXT or WM_SENDTEXT... I feel like I did when to a Roman
Catholic wedding (not trying to offend anyone, as I am Christian) --
but that feeling is I'm familar with what's going on but generally
lost with how to do the 'traditions'.

I almost want to start a thread called "WM_GETTEXT / WM_SENDTEXT for
Newbies/Dummies". I found some app that allows me to view the Control
ID (which I assume is the same as me saying UserForm1.Textbox1.Value)
but still there is no answer as to how to use this code or how to
implement it to do something like send the value of textbox1.value to
Control ID titled "text1".

What's amazing is something that is useful as this isn't explained
very well... it's going to be a whole new world if this is explained
by some genious.- Hide quoted text -

- Show quoted text -



Hope this gets answers... I'm even offering to pay someone to explain
this process... I don't even know how anyone ever learned how to use
this code correctly.

http://groups.google.com/group/micro...b704588?hl=en#

http://groups.google.com/group/micro...b704588?hl=en#

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel cell value equals selected text from Word sarahphonics Excel Discussion (Misc queries) 0 April 19th 10 04:15 PM
Save a selected range to a new text file in excel [email protected] Excel Discussion (Misc queries) 0 October 3rd 06 11:27 PM
How do I get selected text within a cell to remain bold in excel? dixielady Excel Discussion (Misc queries) 2 May 27th 06 09:40 AM
Selecting text in cells & half of the Selected Text to be underLine Manish Singh Excel Programming 3 October 14th 04 07:34 PM
How to create text file from selected excel data Per Magnus L?vold Excel Programming 2 July 22nd 04 05:26 PM


All times are GMT +1. The time now is 07:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"