Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

7.1a macro to select text?

Status
Not open for further replies.

jfly25

Technical User
Mar 16, 2012
5
US
Hi guys,

I'm a newbie and a beginner when it comes to this stuff. I'm using "myExtra Enterprise 7.1a." I need help writing a macro to select certain text in fields on my screen and copy it to the windows clipboard. Where I will then past it into a word document.

My macro is below:

'--------------------------------------------------------------------------------
' This macro was created by the Macro Recorder.
' Session Document: "SESSION1.EDP"
' Date: Thursday, March 15, 2012 18:32:34
' User: c59777
'--------------------------------------------------------------------------------

' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$

Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."
STOP
End If
Set Sessions = System.Sessions

If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If
'--------------------------------------------------------------------------------
' Set the default wait timeout value
g_HostSettleTime = 3000 ' milliseconds

OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If

' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

' This section of code contains the recorded events

' Selects the text, row column to row column
Sess0.Screen.SelectText 3, 19, 3, 43
' Copy the text
Sess0.Screen.Copy
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

System.TimeoutValue = OldSystemTimeout
End Sub



The section below I actually copy/pasted from another post on this forum:

' Selects the text, row column to row column
Sess0.Screen.SelectText 3, 19, 3, 43
' Copy the text
Sess0.Screen.Copy
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

The reason I did this is because I couldn't find a way to record the selecting of text on the screen. Moving the mouse wouldn't record and pressing shift and the arrow keys also wouldn't record....

I need help trying to do this please! Thanks!

 
To add: When I run the above macro I get an EXTRA!Basic Error msg box that pops up and says:
"No such property or method"
"Line number 50"
"Stopping macro playback."

The line 50 of my macro is: Sess0.Screen.SelectText 3, 19, 3, 43

which leads me to believe SelectText isn't the right command to use....

 
Code:
Sess0.Screen.Select(3, 19, 3, 43).copy

from the help file
 
That one doesn't work either....hmmm. I get the same error message when I copy and paste it in place of my wrong one.

"No such property or method"
"Line number 50"
"Stopping macro playback."

Thanks for the post though. Any other suggestions?
 
'--------------------------------------------------------------------------------
' This macro was created by the Macro Recorder.
' Session Document: "SESSION1.EDP"
' Date: Thursday, March 15, 2012 18:32:34
' User: c59777
'--------------------------------------------------------------------------------

' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$

Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."
STOP
End If
Set Sessions = System.Sessions

If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If
'--------------------------------------------------------------------------------
' Set the default wait timeout value
g_HostSettleTime = 3000 ' milliseconds

OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If

' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

' This section of code contains the recorded events

' Selects the text, row column to row column
Sess0.Screen.Select(3, 19, 3, 43).copy
' Copy the text
Sess0.Screen.Copy
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

System.TimeoutValue = OldSystemTimeout
End Sub
 
this is from the help file for 7.1
This example first copies the entire session screen to the Clipboard, then copies an area of the screen to the Clipboard.
Code:
Sub Main()
	Dim Sys As Object, Sess As Object, MyScreen As Object, MyArea As Object

	' Invoke the clipboard viewer
	Shell("clipbrd.exe")

	Set Sys = CreateObject("EXTRA.System")
' Assumes an open session
	Set Sess = Sys.ActiveSession

	' This example demonstrates the Copy method for Screen objects.
	Set MyScreen = Sess.Screen
	MyScreen.SelectAll
	MyScreen.Copy

	MsgBox "The screen was copied to the clipboard. Press to copy a smaller area ..."

' This example demonstrates the Copy method for Area objects.
	Set MyArea = MyScreen.Area(1,1,10,10 , ,)
	MyArea.Select
	MyArea.Copy
End Sub
 
this should work

Code:
Sub Main()

	Dim Sys As Object, Sess As Object
	Set Sys = CreateObject("EXTRA.System")
	Set Sess = Sys.ActiveSession
	Set Sess = Sess.Screen
        sess.Area(3, 19, 3, 43).select
        sess.Area(3, 19, 3, 43).copy
        

End Sub
 
I bow to you sir; it works! You're seriously awesome! One last question to see if I can make the function even better. Say I wanted to select certain areas:
(2, 18, 2, 23)
(3, 19, 3, 43)
(10, 8, 10, 13)

-like pressing ctrl and selecting seperate things on a web site.

Then I need to copy those areas to the clipboard all at once so that when I paste in a word doc, they will all be pasted.

Again, YOU are the man!

I found this help file you mention and see I have a lot to study now.
 
check out copyappend method

Code:
	Dim Sys As Object, Sess As Object
	Set Sys = CreateObject("EXTRA.System")
	Set Sess = Sys.ActiveSession
	Set Sess = Sess.Screen
 
        Sess.area(2, 18, 2, 23).Select
        Sess.CopyAppend
        
        Sess.area(3, 19, 3, 43).Select
        Sess.CopyAppend
        
        Sess.area(10, 8, 10, 13).Select
        Sess.CopyAppend

i learned this from
"thanks to "link99sbc
 
But can these objects be compared to one another? If so, how?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top