Skip to main content

Hello Community,

Is it possible to make a script which works in multiple sheet and if this is possible can you explain how this is possible?

 

I wanted to make a script which has a lot of names and location in the first sheet, which the script can read from. But, when the script has to right down a logfile i want this to be in another sheet. However i don't really know how i make it do this shift between sheets...

 

 


#Rumba

Hello Community,

Is it possible to make a script which works in multiple sheet and if this is possible can you explain how this is possible?

 

I wanted to make a script which has a lot of names and location in the first sheet, which the script can read from. But, when the script has to right down a logfile i want this to be in another sheet. However i don't really know how i make it do this shift between sheets...

 

 


#Rumba

Hi,
you can switch or create new excel sheets from your rumba script code.
Please check out the worksheets.add methods under https://docs.microsoft.com/en-us/office/vba/api/excel.worksheets.add

The code below generates a excel Spreadsheet ,  navigates through a couple of host screens and theend it uses XLSheet2 = XLBook.Worksheets.Add to add a new spreadsheet to the workbook.

rumba code sample:

 

Option Explicit

Sub Main

Dim intRowResult As Integer
Dim intColumnResult As Integer
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim intScreenRow As Integer
Dim intExcelRow As Integer
Dim strData As String
Dim strCell As String


EMSetTN3270 "127.0.0.1",23,2, "ExtendedDS"

SysHide "Timer"

EMStartSession "*", "NavigationDemo"
EMWaitText 30 ,"ENTER SYSTEM ID :" ,12 ,11 , intRowResult, intColumnResult
If ((0 <> NM_ResultCode) Or (12 <> intRowResult) Or (11 <> intColumnResult)) Then
MsgBox "Unable to detect os selection screen (#1)."
Exit Sub
End If

EMSetCursor 12, 29
EMSendKeyFast "VM"

EMSendKey "<ENTER>"
EMWaitText 30, "COMMAND ===>", 23, 2, intRowResult, intColumnResult
If ((0 <> NM_ResultCode) Or (23 <> intRowResult) Or (2 <> intColumnResult)) Then
MsgBox "Unable to detect VM login screen (#2)."
Exit Sub
End If


EMSetCursor 20, 16
EMSendKeyFast "USERNAME"
EMSetCursor 21, 16
EMSendKeyFast "PASSWORD"

EMSendKey "<ENTER>"
EMWaitCursor 30,23, 1
If (0 <> NM_ResultCode) Then
MsgBox "Unable to detect ready screen (#3)."
Exit Sub
End If

EMSendKeyFast "PROFS"
EMSendKey "<ENTER>"
EMWaitText 30, "===>", 23, 1, intRowResult, intColumnResult
If ((0 <> NM_ResultCode) Or (23 <> intRowResult) Or (1 <> intColumnResult)) Then
MsgBox "Unable to detect profs screen (#4)."
Exit Sub
End If

EMSendKeyFast "<PF2>"
EMWaitText 30, "OPEN THE MAIL", 1, 34, intRowResult, intColumnResult
If ((0 <> NM_ResultCode) Or (1 <> intRowResult) Or (34 <> intColumnResult)) Then
MsgBox "Unable to detect mail screen (#5)."
Exit Sub
End If

Set XLApp = CreateObject("Excel.Application")
Set XLBook = XLApp.Workbooks.Add
Set XLSheet = XLBook.Worksheets("Sheet1")
XLSheet.Activate

XLSheet.Range("A1") = "FROM"
XLSheet.Range("B1") = "TO"
XLSheet.Range("C1") = "TYPE"
XLSheet.Range("D1") = "DUE DATE"
XLSheet.Range("E1") = "DOCUMENT NO"
XLSheet.Range("F1") = "SUBJECT"

intExcelRow = 2

For intScreenRow = 6 To 22 Step 2

strData = ""
EMReadScreen strData,19, intScreenRow, 8

If (0 < Len(Trim$(strData))) Then

strCell = "A" & Trim$(Str$(intExcelRow))
XLSheet.Range(strCell) = strData

strData = ""
EMReadScreen strData, 22, intScreenRow, 27
strCell = "B" & Trim$(Str$(intExcelRow))
XLSheet.Range(strCell) = strData

strData = ""
EMReadScreen strData, 8, intScreenRow, 67
strCell = "C" & Trim$(Str$(intExcelRow))
XLSheet.Range(strCell) = strData

strData = ""
EMReadScreen strData, 5, intScreenRow, 76
strCell = "D" & Trim$(Str$(intExcelRow))
XLSheet.Range(strCell) = strData

strData = ""
EMReadScreen strData, 5, intScreenRow, 76
strCell = "E" & Trim$(Str$(intExcelRow))
XLSheet.Range(strCell) = strData

strData = ""
EMReadScreen strData, 60, intScreenRow 1, 20
strCell = "F" & Trim$(Str$(intExcelRow))
XLSheet.Range(strCell) = strData

Else

intExcelRow = 22

End If

intExcelRow = intExcelRow 1

Next intScreenRow

Set XLSheet2 = XLBook.Worksheets.Add
XLSheet2.Name = "LOGS"
XLSheet2.Range("A1") = "WRITING TO Sheet2"

XLSheet.Application.Visible = True

Set XLSheet = Nothing
Set XLBook = Nothing
Set XLApp = Nothing

End Sub

 

Hello Community,

Is it possible to make a script which works in multiple sheet and if this is possible can you explain how this is possible?

 

I wanted to make a script which has a lot of names and location in the first sheet, which the script can read from. But, when the script has to right down a logfile i want this to be in another sheet. However i don't really know how i make it do this shift between sheets...

 

 


#Rumba
i tried using some of the code you have provided, however this seems to only rename the already existing excel file and not actually creating another excel file