×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Pasting from Attachmate into Microsoft word

Pasting from Attachmate into Microsoft word

Pasting from Attachmate into Microsoft word

(OP)
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

RE: Pasting from Attachmate into Microsoft word

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.

RE: Pasting from Attachmate into Microsoft word

(OP)
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,

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close