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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having trouble with paste in Extra Extreme.

Status
Not open for further replies.

link99sbc

Technical User
Apr 8, 2009
141
US
' 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 = 300 ' 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

Dim Sys As Object, Sess As Object, MyScreen As Object, MyArea As Object

Set Sys = CreateObject("EXTRA.System")
Set Sess = Sys.ActiveSession
Set MyScreen = Sess.Screen

'Activates the Spreedsheet which is already open
AppActivate "Microsoft Excel - SCOP stats.xls"

'Copies the active cell and moves down to the next cell which makes it the next active cell.
'I do this more than a 1000 times. "Column with over 1000 names"
Sendkeys "%EC{Down}"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

'Alt tabs back to Extra Session
Sendkeys "%{tab}"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

'Goes to the home position, tabs to the next variable and
'types Name and goes to the next variable (Field) by default
'since only four characters are required in the first field.
Sess0.Screen.Sendkeys("<Home><Tab>NAME")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

'Paste the copied cell from Excel in the second variable space or Field if you prefer.
Sendkeys "%EP"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

'Triggers Extra Session to search a Data Base for the Name that was pasted in the second field.
Sess0.Screen.Sendkeys("<Enter>")

System.TimeoutValue = OldSystemTimeout
End Sub

This works fine in Extra Enterprise but will not paste in Extra Extreme 9.0 SERVICE PAC 2
using "%EP" , Sess0.Screen.paste, MyScreen paste, My Area paste. No matter how I write
it, IT WILL NOT PASTE! Any ideas? It will paste using the mouse or keyboard.
 
you're constantly activating the macro for each cell, right?"
Exactly. If I don't find anything on our database I have research other avenues before I get the next cell.
 


If I don't find anything on our database I have research other avenues before I get the next cell.

It seems to me that you're cutting WAYYYYY short the capabilities of Excel to be able to "automate" this research process.

Let's suppose that you had a macro in Excel, with a similar list. You turn it on and it grabs the first item, gets the IMS screen, reads the appropriate data from the screen, writes it into an Excel sheet, depending on the data, maybe, it decides with database/table it needs to access and accesses that data and returns it to an Excel sheet, relating it to the data returned from the IMS screen, etc, etc until the list is exhausted. It might go to half a dozen or more different sources to gather the data, rather than YOU haveing to do all that work yourself.

I have data access programs that go one place to attempt to return data. If nothing is returned then it goes another place. No big deal.

I have data access programs that join 6 or 8 different tables in order to get the data I need.

I have nearly 100 data access functions that return ONE piece of data, given one or more parameters: greta for getting the On Hand balance for a Part, or the requirements for a Part between two dates. And the list goes on and on.

There are all kind of ways to get data "automatically"



Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
In a perfect office this would be great but I have to research other agency databases which we have access to but for security issues require a login and password which we are not allowed to write down anywhere. I also have to research the internet so sometimes what I'm looking for is not always specific but general information. Just getting what I need from the active cell helps alot. I only use Excel as the list of Names OR Numbers to research. Once I get the name or number in my Extra Session and search our database I can determine if it requires further research. Sometimes it doesn't and I move on to the next one. So all I need is a code that will do the same in Extra as it does in excel. Just get the active cell, or get the active cell and enter a 1 in the appropriate column. Should be pretty simple for a wizard such as yourself.
 


So all I need is a code that will do the same in Extra as it does in excel

So you want to code in an application that has less flexibility and using code that has fewer capabiltites?

Is that what I understand you want to do?

And for what reason?

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
So I don't have to go from Extra to Excel 1500 times to run the excel macro.
 


Now I am confused!

If you are in Excel, then you do not have to go from ANYWHERE to ANYWHERE to run an Excel macro.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
hi link99sbc,

i don't have Extra Extreme 9.0 SERVICE PAC 2, but did you check the Edit options in Extra?

your original statement was you couldn't get it to paste using 9.0 but using Enterprise it was ok

zach
 
zach
Yes I checked the Edit Options. This is just an annomally that attachmate doesn't want to deal with. So I thought I could use a code to put the contents of the active cell in my field instead of copy & paste.
This code in Excel does exactly what I want it to do but I have to go from Extra to Excel 1500 times to run the macro. I was wanting to stay in Extra and run the macro that accomplishes the same thing without having to go to the Excel screen each time.
Code:
Sub clear()

    ActiveCell.Offset(0, -2) = 1
    ActiveCell.Offset(1, 0).Activate
    
    Dim Sessions As Object
    Dim System As Object
    Set System = CreateObject("EXTRA.System")
    Dim Sess0 As Object
    Set Sess0 = System.ActiveSession
    Set Field = System.ActiveSession.Screen.Area(4, 18, 4, 26)
    Field.Select
    Field.Delete
    Field.Value = ActiveCell
    SendKeys "%{TAB}+~"    'This Alt tabs back to Extra and sendkey <enter>

    
End Sub
Sub bill()

    ActiveCell.Offset(0, -1) = 1
    ActiveCell.Offset(1, 0).Activate
    
    Dim Sessions As Object
    Dim System As Object
    Set System = CreateObject("EXTRA.System")
    Dim Sess0 As Object
    Set Sess0 = System.ActiveSession
    Set Field = System.ActiveSession.Screen.Area(4, 18, 4, 26)
    Field.Select
    Field.Delete
    Field.Value = ActiveCell
    SendKeys "%{TAB}+~"   'This Alt tabs back to Extra and sendkey <enter>
    
End Sub
 
link99sbc,

try changing
Code:
g_HostSettleTime = 300
to
Code:
g_HostSettleTime = 1000

your code is running too quick...

i tried this with extreme 8 and it took a few tries...

this works as well
Code:
sess0.screen.paste


what's really strange is that i cannot get it to work all the time...sometimes Sendkeys "%EC{Down}" doesn't always send the {Down}....



zach
 
I know the feeling. Sometimes {Enter} doesn't always work so i use +{Enter} and that seems to do the trick. I haven't had any problem with {down}. I will try what you suggest. I think I already tried that but I'll try it again.

I would still like to know how to code this in Extra so I don't have to use copy and paste. I think its a matter of getting the object correct and putting the value of the object which is the active cell at the specified location plus making the active cell offset 1 row and activate that cell. I got one to compile today but it's not putting anything in the field.
 
link99sbc,

from what i see, with the existing coding you have in Extra with copy & paste, that does work. there's nothing wrong with it.
did you try changing the g_hostSettle time ?
 
OMG it works. Must be too much code for 300 milliseconds
600 works ok too. Still like to know how to code it like VB. Thanks
 

you had the correct code all along...it was a lousy timing issue

glad it worked for you

let me know when YOU figure out how to code in VB :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top