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
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