VBA Wrq Reflection IBM3270

el_jm

New Member
Joined
Oct 21, 2014
Messages
21
Hello, I am using a loop to copy/ paste data from 0190.csv file (A column) to client (field 3, 30) in order to get
an internal reference appearing afterwards in client 3, 14 field.

My aim is to copy-paste data from client field 3, 14 to a new excel file.
I am able to move my cursor to that field (3, 14) but
do not how to collect (coy paste?) this data to a new excel file, ideally placed in the same Directory
"H:\Spain\Data_Collected.xls"
Here's my code fisrt lines...
If someone has an idea & an explanation on how to do this, I would be very interested.
Thanks,



Sub GET_DATA()
'
Dim Title, Default, fileloc, strLine, arrValues, fso, inputFileStream
Dim line As String
With Session
fileloc = "H:\Spain\0190.csv" ' Set default
Const conStrSeparator = ";"
Set fso = CreateObject("Scripting.FileSystemObject")
Set inputFileStream = fso.OpenTextFile("H:\Spain\0190.csv", 1, False, 0)
Do Until inputFileStream.AtEndOfStream
strLine = inputFileStream.ReadLine
arrValues = Split(strLine, conStrSeparator)
.WaitForEvent rcKbdEnabled, "0", "1", 3, 58
.MoveCursor 3, 30 'campo REF de PODHIS
.TransmitTerminalKey rcIBMEraseEOFKey
.TransmitANSI arrValues(0)
.TransmitTerminalKey rcIBMPf1Key
.WaitForEvent rcKbdEnabled, "0", "1", 58, 8
.MoveCursor 3, 14 'CAMPO A COPIAR
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi,

Do you want to save the whole .csv file as an Excel file or just part of it.

I assume Excel will be installed on the appropriate server?

If so there are ways to open and control Excel from VBScript. If you want to save the whole .csv file then it might be easiest to just open the .csv file with Excel and save it to another file. If you only need part of the .csv file then one plan would be to read the records as you are doing and deciding which ones to save before copying into Excel.
 
Upvote 0
Hi,

Do you want to save the whole .csv file as an Excel file or just part of it.

I assume Excel will be installed on the appropriate server?

If so there are ways to open and control Excel from VBScript. If you want to save the whole .csv file then it might be easiest to just open the .csv file with Excel and save it to another file. If you only need part of the .csv file then one plan would be to read the records as you are doing and deciding which ones to save before copying into Excel.

Hi, Yes excel is available on the server.
Actually I am looking for a script that generates a simple vertical list of data stored on "3, 14" field ... which is the point where I stopped my code (and do this till end of my .csv list).
I do not know if my explanations are clear enough.
 
Upvote 0
Hi,

Here is a simple script that will open Excel, write some data to a cell, save the workbook then close Excel.

Code:
' Set Excel FileName
strFileName    = H:\Spain\0190.xlsx"

' Create Excel Objects
set objXL     = WScript.CreateObject("Excel.Application")

' Show Excel
objXL.Visible = TRUE      

' Add a new workbook
Set objWorkbook = objXL.Workbooks.Add

' Write to a cell (Row, Col)
objXL.Cells(1, 1).Value = "Test value"

' Save the workbook
objWorkbook.SaveAs(strFileName)

' Quit Excel
objXL.quit

' Tidy Up
Set objXL = nothing
You should probably be able to work that into your script now.

EDIT: Nearly forgot - here is a link to some VBScripts that control Excel: Microsoft Excel VBScript Script samples
 
Upvote 0

Forum statistics

Threads
1,223,713
Messages
6,174,043
Members
452,542
Latest member
Bricklin

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