Saturday, 5 November 2016

Excel Screen Shot File:

'Option Explicit
Sub createxls()
Dim ibmCurrentTerminal As IbmTerminal
Dim ibmCurrentScreen As IbmScreen
Dim hiddenTextEntry As String
Dim returnValue As Integer
Dim timeout As Integer
Dim waitText As String
timeout = 15000
Set ibmCurrentTerminal = ThisFrame.SelectedView.control
Set ibmCurrentScreen = ibmCurrentTerminal.Screen

On Error Resume Next
Dim Root, Filepath, Imagepath, Objxl, iCountwb, wb, oSnapxl, i
Dim osnapsheet, osnaprows, wbs, usedrow, pasteAt
Root = "C:\Users\sunshine\Desktop\Data\"
Filepath = Root & "log.xlsx"
Imagepath = Root + "ReflectionScreen.bmp"
'MsgBox Filepath
'MsgBox Imagepath
Set Objxl = GetObject(, "Excel.Application")
'Gives runtime Error 429 if object not found
'On Error GoTo 0
If Err = 429 Then
MsgBox "Excel Not Running", vbInformation, "Excel.Status"
Set Objxl = CreateObject("Excel.Application")

Else

'MsgBox Objxl.workbooks.Count

Set snapxl = Nothing
For Each wb In Objxl.workbooks
'*********************************************8
If wb.Name = "log.xlsx" Then
'Set oSnapxl = Objxl
Set snapxl = wb
'Set osnapsheet = oSnapxl.worksheets(1)
Set osnapsheet = snapxl.worksheets(1)
Exit For
End If
Next
Dim snapxlvalue

MsgBox snapxl
'*********************************************8
End If
one = snapxl

'If snapxl Is Nothing Or snapxl = Empty Then
If IsEmpty(snapxl) Then
Set osnapwb = Objxl.workbooks.add()

osnapwb.Visible = True
'Objxl.Visible = True

Set osnapsheet = osnapwb.worksheets(1)


End If

'MsgBox snapxl

usedrow = osnapsheet.usedrange.rows.Count
lcol = 1
For Each shp In osnapsheet.Shapes
        If shp.BottomRightCell.column > lcol Then _
        lcol = shp.BottomRightCell.column
        lrow = shp.BottomRightCell.row
        'MsgBox lcol & lrow
       
       
        Next
       
        With osnapsheet.Pictures.Insert("C:\Users\sunshine\Desktop\Data\ReflectionScreen.bmp")
        With .ShapeRange
        .LockAspectRatio = msoTrue
        .Width = 820
        .Height = 426
    End With
    .Left = osnapsheet.cells(lrow + 5, 3).Left
    .top = osnapsheet.cells(lrow + 5, 3).top
    .Placement = 1
    .PrintObject = True
End With

Objxl.DisplayAlerts = False
osnapsheet.SaveAs (Filepath)




'End If

End Sub


Sub main()

Dim ibmCurrentTerminal As IbmTerminal
Dim ibmCurrentScreen As IbmScreen
Dim hiddenTextEntry As String
Dim returnValue As Integer
Dim timeout As Integer
Dim waitText As String
timeout = 15000

Set ibmCurrentTerminal = ThisFrame.SelectedView.control
Set ibmCurrentScreen = ibmCurrentTerminal.Screen


createxls
'Openxls
 Wait 3000

ibmCurrentScreen.SendKeys "hi"
createxls

ibmCurrentScreen.SendKeys "bye"
createxlslast "C:\Users\sunshine\Desktop\Data\loglast.xlsx"



End Sub



'Option Explicit
Sub createxlslast(strfilepath2)
Dim ibmCurrentTerminal As IbmTerminal
Dim ibmCurrentScreen As IbmScreen
Dim hiddenTextEntry As String
Dim returnValue As Integer
Dim timeout As Integer
Dim waitText As String
timeout = 15000
Set ibmCurrentTerminal = ThisFrame.SelectedView.control
Set ibmCurrentScreen = ibmCurrentTerminal.Screen

On Error Resume Next
Dim Root, Filepath, Imagepath, Objxl, iCountwb, wb, oSnapxl, i
Dim osnapsheet, osnaprows, wbs, usedrow, pasteAt
Root = "C:\Users\sunshine\Desktop\Data\"
strfilepath2 = Root & "loglast.xlsx"
Imagepath = Root + "ReflectionScreen.bmp"
'MsgBox Filepath
'MsgBox Imagepath
Set Objxl = GetObject(, "Excel.Application")
'Gives runtime Error 429 if object not found
'On Error GoTo 0
If Err = 429 Then
MsgBox "Excel Not Running", vbInformation, "Excel.Status"
Set Objxl = CreateObject("Excel.Application")

Else

'MsgBox Objxl.workbooks.Count

Set snapxl = Nothing
For Each wb In Objxl.workbooks
'*********************************************8
If wb.Name = "log.xlsx" Then
'Set oSnapxl = Objxl
Set snapxl = wb
'Set osnapsheet = oSnapxl.worksheets(1)
Set osnapsheet = snapxl.worksheets(1)
Exit For
End If
Next
Dim snapxlvalue

MsgBox snapxl
'*********************************************8
End If
one = snapxl

'If snapxl Is Nothing Or snapxl = Empty Then
If IsEmpty(snapxl) Then
Set osnapwb = Objxl.workbooks.add()

'osnapwb.Visible = True
Objxl.Visible = True

Set osnapsheet = osnapwb.worksheets(1)


End If

'MsgBox snapxl

usedrow = osnapsheet.usedrange.rows.Count
lcol = 1
For Each shp In osnapsheet.Shapes
        If shp.BottomRightCell.column > lcol Then _
        lcol = shp.BottomRightCell.column
        lrow = shp.BottomRightCell.row
        'MsgBox lcol & lrow
       
       
        Next
       
        With osnapsheet.Pictures.Insert("C:\Users\sunshine\Desktop\Data\ReflectionScreen.bmp")
        With .ShapeRange
        .LockAspectRatio = msoTrue
        .Width = 820
        .Height = 426
    End With
    .Left = osnapsheet.cells(lrow + 5, 3).Left
    .top = osnapsheet.cells(lrow + 5, 3).top
    .Placement = 1
    .PrintObject = True
End With

Objxl.DisplayAlerts = False
osnapsheet.SaveAs (strfilepath2)
 Objxl.Quit




'End If

End Sub

Spring Boot : Exception Handler 14