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

Exporting Data from Attachmate 1

Status
Not open for further replies.

Dklein

IS-IT--Management
Nov 9, 2001
33
US
Hi,

Can anyone help please, I've not coded before in VB but have used the record funtions whenever I need to complete an automated action.

I now need to take data from an Attachmate screen and put it into a text document or even better in an excel spreadsheet. If someone could give be an example end-to-end code I could manipulate I would really appreciate it. or any help would be great.

Thanks in anticipation.

Dklein
 
I don't have code but I could tell you how to do it.

Normally, you could sendkeys
send alt-e to edit
send an s to select the entire screen
send alt-e to edit
send alt-c to copy the screen into the buffer

Then you should be able to access the buffer and paste it into excel or whatever.

But be forewarned that the sendkey option is not the most stable thing in the world.
 
Hi,
To write data from screen and put to an excel file you have to use the getstring command, open a file for output (CSV file) and write this file with the information.

This is an example:

Msg$ = "Welcome to Data entry Macro for big supplier reading an text file, Please enter the drive where you want to open the excel file booking.csv"
Drive$ = UCase$(Left$(InputBox$(Msg$), 1)) ' Get user input.


' This section open the input and the output file
If Drive$ = "C" or Drive$ = "A" Then
FileOut$ = Drive$ + ":\approval.csv"
If Dir$(FileName$) <> &quot;&quot; Then ' Check if file exists.
Open FileOut$ For Output As #2 ' It open an output file for write
Else ' No prueba.txt.
Msg$ = &quot;Could not find a prueba.txt file on drive &quot;
Msg$ = Msg$ + UCase$(Drive$) + &quot;:&quot;
End If
Else
Msg$ = &quot;You did not provide a valid file &quot;
Msg$ = Msg$ + &quot;check in unit A: or C: drive.&quot;
End If

Do
For FacturasPorPagina= 0 to 6 step 1
TablaProvision(TotalFacturas,0)=MyScreen.Getstring(FacturasPorPagina*2 + 10, 02, 02)
TablaProvision(TotalFacturas,1)=MyScreen.Getstring(FacturasPorPagina*2 + 10, 05, 06)
TablaProvision(TotalFacturas,2)=MyScreen.Getstring(FacturasPorPagina*2 + 10, 48, 15)
If Instr(TablaProvision(TotalFacturas,2),&quot;,&quot;) Then
poscomma = Instr(TablaProvision(TotalFacturas,2),&quot;,&quot;)
Mid(TablaProvision(TotalFacturas,2), poscomma) = &quot;.&quot;
end if
TablaProvision(TotalFacturas,3)=MyScreen.Getstring(FacturasPorPagina*2 + 10, 66, 03)
TablaProvision(TotalFacturas,4)=MyScreen.Getstring(FacturasPorPagina*2 + 10, 17, 20)
TablaProvision(TotalFacturas,5)=MyScreen.Getstring(FacturasPorPagina*2 + 11, 10, 25)
TablaProvision(TotalFacturas,6)=MyScreen.Getstring(FacturasPorPagina*2 + 11, 51, 8)

If TablaProvision(TotalFacturas,0) = &quot; &quot; Then
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
exit do
End if
TotalFacturas = TotalFacturas + 1
If FacturasPorPagina=5 Then
Sess0.Screen.Sendkeys(&quot;<pf2>&quot;)
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
FacturasPorPagina= 0
End if
Next FacturasPorPagina
loop




For ImprimirTabla = 0 to TotalFacturas Step 1
For Variables = 0 to 6 Step 1
Print #2, TablaProvision(ImprimirTabla,Variables)& &quot;,&quot;;
Next Variables
Print #2,
Next ImprimirTabla

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top