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

Caputring Data to a file using a macro

Status
Not open for further replies.

mytime21

Programmer
Apr 3, 2006
31
US
I have been able to record a macro that will run the report and stick it in the spooler for me. I need to be able to make the capture incoming data work while running a macro to be able to send the data to a file. I am a beginner in this. The data that goes to the file is variable and can range from about 20,000 lines to 30,000 lines. Can anyone help me to be able to capture the data from the spooler into a file using a macro???
 
I created the new macro and it displays a box that says 36 to me.
 
One more idea, since you can Select the entire report let's try duplicating it with the following code. It Selects the entire area of the screen (in my situation it grabs all 24 rows) with any luck it will grab all the rows of your scrolling screen. Again I don't have scrolling screen so lets keep our fingers crossed. If it works we can start cleaning up this code.
Code:
'--------------------------------------------------------------------------------
' This macro was created by the Macro Recorder.
'--------------------------------------------------------------------------------

' 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
    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.Connected = True    
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
    Sess0.Screen.Sendkeys("vista<Ctrl+M>")    
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
    Sess0.Screen.Sendkeys("<Tab>")    
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
    Sess0.Screen.Sendkeys("<Ctrl+M>")    
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
    Sess0.Screen.Sendkeys("ma<Ctrl+M>")    
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
    Sess0.Screen.Sendkeys("spo<Ctrl+M>")    
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
    Sess0.Screen.Sendkeys("p<Ctrl+M>")    
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
    Sess0.Screen.Sendkeys("ryan mar<Ctrl+M>")    
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
    Sess0.Screen.Sendkeys("1<Ctrl+M>")    
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
    Sess0.Screen.Sendkeys("<Keypad 0>;<Keypad 2><Keypad 4><Keypad 0>;<Keypad 9><Keypad 9><Keypad 9><Keypad 9><Keypad 9><Keypad 9><Keypad Enter><Ctrl+M>")    
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
    Sess0.Screen.Sendkeys("<Ctrl+M>")    
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
    Sess0.Screen.Sendkeys("<Ctrl+M>")    
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

    Open "c:\texttest.txt For OutPut As #1
         print #1,Sess0.Screen.SelectAll.Value
    Next
    Close #1

    System.TimeoutValue = OldSystemTimeout
End Sub

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
36 means the Rows() isn't going to give us the number of lines in your scrolling screen :( We'll have to look for some other property.

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
Anyone with any knowledge of the "Scrolling Screen" feel free to help us out here.

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
I tried just selecting all and then stopping the macro to see what it looked like. It still is not working. MAn, this is really kicking my butt.

Can you direct me to a place that has a list of the different functions and terms for writing macros using attachmate
 
The help files in my Editor are the only ones i've ever used. You should have a copy in your attachmate folder.

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
I found a nice little feature in Enterpris it allows me to retain the history to a file with an extension ".HIS". Notepad does not read this file. Only a KEA emulator session will read it. SO that does not work either.
 
Found a VB reference with scrolling screen in the Access Database Forum posted by CautionMP. I think I can work this into EB for you when I have a free minute.

Here's the Faq if you want to take a look.

faq181-4619

Does F8 scroll your screen or is it some other key?
CautionMP said:
'In my world F8 scrolls down so 1<PF8> will scroll 1 line
objExtraScreen.SendKeys ("1<PF8>")


[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
I found a nice little feature in Enterpris it allows me to retain the history to a file with an extension ".HIS". Notepad does not read this file. Only a KEA emulator session will read it. SO that does not work either.

What does it do if you save the file as .HIS then drop the extension and open in notepad?

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
Open your macro editor and create a new macro like this and run it while your report is displayed on the screen.

Sub Main()
msgbox cstr(CreateObject("EXTRA.System").ActiveSession.Screen.SelectAll.Value
End Sub

Do you get 35 lines or the whole report?

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
I will try your last suggestion. The HIS extendion if dropped gives a whole bunch of code that is not readable in text format. Also, I have the option of just browsing the document and then I can do a "f1 B" function and it will jump to the bottom of the document where the last line always states " |TOP| ". Also their is a is a funciton called " F1 C " that will allow me to copy the entire text of the report and it places it on what the help calls the Fileman clipboard but it states " Text Copied to Buffer " Any idea on how to make the buffer print to the file???
 
See if you can paste it from the buffer in your session>Edit>paste from buffer.

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
To much cut and paste it should have been

Sub Main()
msgbox CreateObject("EXTRA.System").ActiveSession.Screen.SelectAll.Value
End Sub

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
THe 35 lines would not work. I do not have apaste from Buffer under Any of the drop down menus. When I clicked on paste it paste something I copied on windows not what was copied onto the buffer.
 
try this again and tell me what you get in the msgbox.

Sub Main()
msgbox CreateObject("EXTRA.System").ActiveSession.Screen.SelectAll.Value
End Sub

It may have not worked because I had a format issue from cutting and pasting (wish I was a faster typist).

I had remnants of cstr() which gives us the string value of an object/variant but ActiveSession.Screen.SelectAll.Value returns a string so it was unessasary to use cstr() and I forgot the closing ) anyhow Cstr( does not work [lol]

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
Is there a [tt]Stream[/tt] or [tt]TextStream[/tt] object in the version your using?

If there is I think this is the object you want to work with as it will allow you to capture everything that is sent from the host to your client.

It's been a while since I have done any work with host sessions (I know longer work for a company that uses them) but I seem to remember some type of [tt]Stream[/tt] object was available for certain session types.

Hope this helps,
CMP

(GMT-07:00) Mountain Time (US & Canada)
 
HOw do I know if I have a streamObject or such as Strem or TextStream. I am using the Enterprise edition.
 
In the Macro Editor search the Help file for 'stream'. This will tell you if it exists and if it does it will gove a simple example of how it would be used in a macro.

CMP

(GMT-07:00) Mountain Time (US & Canada)
 
A Little cleanup here: The message box macro displays just the last screen.

I was afraid of this, but the help is not loaded in the editor for the enterprise edition. I think they did not want to load it here at my job. I will see if there is a way fo rme to get my hands on it.
 
mytime21 said:
I have the option of just browsing the document and then I can do a "f1 B" function and it will jump to the bottom

What commands do you use to 'browse' the document? Does this mean you can scroll up/down pages (was it 36 lines per 'page')? What do you type to change your position in the report?

CMP

(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top