I need to scrape a host report to an external format. I go for about any format in fact. I used the following to send the screen scrape to a printer, any idea how I can append it to a file instead of sending it to a printer? The code I use to print is -
Dim rc%
Dim MaxColumn%
Dim row%
Dim MaxRows%
Dim filenum%
Dim Screenbuf$
Dim linebuf$
Dim FileName$
' 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
Sess0.Screen.Sendkeys("<Home>"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("xqd<Enter>"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("57221000000<Enter>"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Set Sess0=System.ActiveSession
Set MyScreen=Sess0.Screen
FileIn=FreeFile
'Takes a "snapshot" of current screen and stores it in variable Screenbuf$
MaxRows%=Sess0.Screen.Rows()
MaxColumns%=Sess0.Screen.Cols()
Screenbuf$=""
linebuf$=Space$(MaxColumns%)
For row%=1 to MaxRows%
linebuf$=Sess0.Screen.Area(row%,1,row%,MaxColumns%,xBlock)
Screenbuf$=Screenbuf$+linebuf$+Chr$(13)+Chr$(10)
Next
filenum%=Freefile
FileName$="\\BDCTAPE\HP_Eastwing" 'name of your network printer
Open FileName$ For Output as filenum%
Print # filenum%,screenbuf$; chr$(12) 'this actually sends the screen print to the printer
Close filenum%
Dim rc%
Dim MaxColumn%
Dim row%
Dim MaxRows%
Dim filenum%
Dim Screenbuf$
Dim linebuf$
Dim FileName$
' 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
Sess0.Screen.Sendkeys("<Home>"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("xqd<Enter>"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("57221000000<Enter>"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Set Sess0=System.ActiveSession
Set MyScreen=Sess0.Screen
FileIn=FreeFile
'Takes a "snapshot" of current screen and stores it in variable Screenbuf$
MaxRows%=Sess0.Screen.Rows()
MaxColumns%=Sess0.Screen.Cols()
Screenbuf$=""
linebuf$=Space$(MaxColumns%)
For row%=1 to MaxRows%
linebuf$=Sess0.Screen.Area(row%,1,row%,MaxColumns%,xBlock)
Screenbuf$=Screenbuf$+linebuf$+Chr$(13)+Chr$(10)
Next
filenum%=Freefile
FileName$="\\BDCTAPE\HP_Eastwing" 'name of your network printer
Open FileName$ For Output as filenum%
Print # filenum%,screenbuf$; chr$(12) 'this actually sends the screen print to the printer
Close filenum%