Attachmate macro incorporating a line break - does anyone work with Attachmate macros?

stressler

Board Regular
Joined
Jun 25, 2014
Messages
95
I have a macro that needs to incorporate a line break when scraping data and exporting to a csv file. I have the macro built, but the line break isn't executing correctly. Does anyone have Attachmate platform macro experience to help me?

Here's my macro that currently has a line break code in it...

'--------------------------------------------------------------------------------
' This macro was created by the Macro Recorder.
' Session Document: "Hogan2023.edp"
' Date: Monday, December 07, 2015 12:59:18
' User: N888098
'--------------------------------------------------------------------------------

' 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 = 0 ' 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)
Close 1
Open "H:\My Documents\outputfile.csv" For Output As 1

' This section of code contains the recorded events
Sess0.QuickPads("HOGAN SHORTCUT BUTTONS").Visible = True
Sess0.QuickPads("S&S SHORTCUT BUTTONS").Visible = True
Sess0.Screen.Sendkeys("<Clear><Clear>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("RE15<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.WaitForCursor 1,75
Sess0.QuickPads("HOGAN SHORTCUT BUTTONS").Visible = True
Sess0.QuickPads("S&S SHORTCUT BUTTONS").Visible = True
Sess0.Screen.Sendkeys("<Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.WaitForCursor 8,2
Sess0.QuickPads("HOGAN SHORTCUT BUTTONS").Visible = True
Sess0.QuickPads("S&S SHORTCUT BUTTONS").Visible = True
Sess0.Screen.Sendkeys("x<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Do
CycleDate = Sess0.Screen.Area(2,14,2,23)
TRNPosition = InStr(1, Sess0.Screen.Area(18, 13, 19, 80), "TRN#")
If TRNPosition = 0 Then TRN = "TRN not found"
If TRNPosition > 61 And TRNPosition < 72 Then
TRN = Mid(Sess0.Screen.Area(18, 13, 19, 80), TRNPosition + 4, 76 - (TRNPosition + 1)) & Sess0.Screen.Area(19, 13, 19, (12 - (76 - (TRNPosition + 1))))
Else
TRN = Mid(Sess0.Screen.Area(18, 13, 19, 80), TRNPosition + 4, 12)
End If
Print #1, CycleDate & "," & TRN
System.TimeoutValue = OldSystemTimeout
Sess0.Screen.Sendkeys("<Pf8>")
Loop Until Sess0.Screen.Area(1,2,1,4) = Sess0.Screen.Area(1,9,1,11)
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
CycleDate = Sess0.Screen.Area(2,14,2,23)
TRNPosition = InStr(1, Sess0.Screen.Area(18, 13, 19, 80), "TRN#")
If TRNPosition = 0 Then TRN = "TRN not found"
If TRNPosition > 61 And TRNPosition < 72 Then
TRN = Mid(Sess0.Screen.Area(18, 13, 19, 80), TRNPosition + 4, 76 - (TRNPosition + 1)) & Sess0.Screen.Area(19, 13, 19, (12 - (76 - (TRNPosition + 1))))
Else
TRN = Mid(Sess0.Screen.Area(18, 13, 19, 80), TRNPosition + 4, 12)
End If
Print #1, CycleDate & "," & TRN
System.TimeoutValue = OldSystemTimeout
Close 1
End Sub


And here are the lines specific to my line break, as shown above in the full macro...
TRNPosition = InStr(1, Sess0.Screen.Area(18, 13, 19, 80), "TRN#")
If TRNPosition = 0 Then TRN = "TRN not found"
If TRNPosition > 61 And TRNPosition < 72 Then
TRN = Mid(Sess0.Screen.Area(18, 13, 19, 80), TRNPosition + 4, 76 - (TRNPosition + 1)) & Sess0.Screen.Area(19, 13, 19, (12 - (76 - (TRNPosition + 1))))
Else
TRN = Mid(Sess0.Screen.Area(18, 13, 19, 80), TRNPosition + 4, 12)
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,216,074
Messages
6,128,649
Members
449,462
Latest member
Chislobog

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top