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

Pasting from Attachmate into Microsoft word

Status
Not open for further replies.

tadisc

Technical User
Jul 22, 2014
6
US
Hello all,

I am currently working on a macro that can copy a selection from attachmate EXTRA!, and then paste it into a word document. Then I want to go to the next page and do the same thing, repeating until it is done. I know C, C++, VHDL, and assembly, so i know programming, but have never actually worked with VB so im a beginner when it comes to this. Right now I have the program copying and appending, and opening a word document, but I am not sure how to paste it into the doc. Can anyone help? Thanks!



' 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, MyScreen As Object, MyArea 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)

---------------------------------------------------------------------------
' Declare Object Variables
Dim objApp As Object
Dim objDoc As Object
Dim objRange As Object

'if word not running, GetObject(...) will return a 429 error.
'Therefore tell macro to keep running if an error raised

On Error Resume Next

'try to grab a reference to an open instance of word
Set objApp = GetObject(, "Word.Application.8")

'if getobject(..) failed to return an object, then
If objApp Is Nothing Then

Set objApp = CreateObject("Word.Application.8")

'if objApp is still nothing, word is not installed. Exit the macro
If objApp Is Nothing Then Exit Sub

End If

'make word visible to user
objApp.Visible = True

'Create a new, blank, untitled document and assign it to objDoc
Set objDoc = objApp.Documents.Add

System.TimeoutValue = OldSystemTimeout

Set MyScreen = Sess0.Screen
Set MyArea = MyScreen.Area(8, 6, 22, 62)
MyArea.Select
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Copy
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

Do

Sess0.Screen.Sendkeys("<Pf8>")
Sess0.Screen.WaitHostQuiet(45)
Set MyArea = MyScreen.Area(8, 6, 22, 62)
MyArea.Select
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.CopyAppend

Loop While Sess0.Screen.GetString(24, 11, 44) <> "NO MORE DATA TO SCROLL IN FORWARD DIRECTION"
'ends when you cannot scroll anymore

End Sub
 
Hi,

Curious regarding a couple of issues.

1. Why are you using a word processor as the target for your data from your terminal emulator? I've rarely seen a screen that contains prose. Usually data elements that are best stored in some sort of tabular structure.

2. Would you predetermine, for instance, "I'll stop at every traffic light, regardless if the signal is red or green, for 30 seconds: then proceed through the intersection?

You're working with an asynchronous system, and must wait for a response. It could be seemingly instantaneous or it could take second, minutes, or the transaction may even be A transaction outage with no response until some maintenance action is performed.

I often preform a loop using WaitForCursor at the screen rest coordinates.
 
Thanks for your quick reply!

Basically the field that I am trying to copy and paste contains text. Id like to copy that field, and then paste it into Microsoft Word, and then copy and paste continuously until i cannot scroll anymore on the page. My programming is pretty rough around the edges so I am not exactly sure how to wait for the correct response instead of just waiting for a finite amount of time.

Thanks,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top