I would like to create a script in Excel to look at my IBM Personal Communications Screen or data source(preferred) and then to parse that screen text into cells.
Any ideas on where to even begin?
I would like to create a script in Excel to look at my IBM Personal Communications Screen or data source(preferred) and then to parse that screen text into cells.
Any ideas on where to even begin?
You can use a VBScript macro in IBM Personal Communicagtions. Here is a sample script that will read information from the screen and then send that information to an Excel spreadsheet.
[PCOMM SCRIPT HEADER]
LANGUAGE=VBSCRIPT
DESCRIPTION=Paste to Excel
[PCOMM SCRIPT SOURCE]
Dim wsh
Set wsh=CreateObject("WScript.Shell")
Dim pComm5250
' Set up Variables
Dim ReadThis
Dim strArray
Dim i
'
' Get Presentation Space of current emulator window
autECLSession.SetConnectionByName(ThisSessionName)
Set pComm5250=autECLSession.autECLPS
' Set up a Function for correcting the case of names
Function PCase(strInput)
Dim i, x, strOut, flg
flg = True
For i = 1 To Len(strInput)
x = LCase(Mid(strInput, i, 1))
If Not IsNumeric(x) And (x < "a" Or x > "z") Then
flg = True
ElseIf flg Then
x = UCase(x)
flg = False
End If
strOut = strOut & x
Next
PCase = strOut
End Function
' The first two numbers are the screen location row and column. The third number is how many characters to read.
autECLSession.autECLOIA.WaitForInputReady
ReadThis=pComm5250.GetText(1,2,10)
' Trim any extra blank spaces to the right
ReadThis=RTrim(ReadThis)
' If the variable is numbers, you use this to replace any blank space with a "0".
ReadThis=Replace(ReadThis," ","0")
' If the variable is text you can do this to capitalize each word
ReadThis=PCase(ReadThis)
'Create the excel object
set objExcel = CreateObject("Excel.Application")
'View the Excel program and file, set to false to hide the whole process
objExcel.Visible = True
'Open the excel file
Set objWorkbook = objExcel.Workbooks.Open("C:\Path\ExcelFile.xlsm", , True)
'Set the cell value at row 2 column 3
objExcel.Cells(2,3).Value = (ReadThis)
Set wsh=Nothing
Set pComm5250=Nothing
I would handle this using SQL inside of Excel. This technique will not grab data from your display file. It will instead use your second option of getting it from the underlying database tables.
.odc
file with connection information to get to the IBM i DB2 database. On my PC, ODBC and OLE DB drivers were installed along with the emulator so that you can connect to the IBM i using Microsoft protocols.SELECT
statement: joins, CTE's, sub-queries, anything that is well-formed DB2 for i SQL..odc
source.