[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need Help



This has nothing to do with the topic of this mailing list, and does not belong here.

On 1/21/2016 1:22 PM, Nikhil Rustagi wrote:
    Hi,
    I know that this might not be the right forum to bring up my question.
    But I will be really thankful if anyone of you can help me out on this.
    I need to get to this by this Saturday.
    I need to create a macro in AS400 which picks data from Excel and
    populated the AS400 display file. I got some examples from internet but
    none of them seem to be working. The latest is the below vb script I
    tried to run but throws an error. The error it says is that this line
    is not valid 'Set ObjExcelAppl = CreateObject(�Excel.Application�)'.
    [PCOMM SCRIPT HEADER]
    LANGUAGE=VBSCRIPT
    DESCRIPTION=
    [PCOMM SCRIPT SOURCE]
    OPTION EXPLICIT
    autECLSession.SetConnectionByName(ThisSessionName)
    Dim ObjExcelAppl, ObjWorkbook, ObjWorksheet, StrFileName
    Dim cCol1, cCol2
    Dim c1, c2
    �
    Main
    Set ObjWorksheet = Nothing
    Set ObjWorkbook = Nothing
    Set ObjExcelAppl = Nothing
    �
    Sub Main()
    �
    �  �  Set ObjExcelAppl = CreateObject(�Excel.Application�)
    �  �  StrFileName = ObjExcelAppl.GetOpenFilename _
    �  �  �  �  (�Microsoft Excel bestanden (*.xls*),*.xls*�)
    �  �  ObjExcelAppl.DisplayAlerts = False
    �
    �  �  If StrFileName <> False then
    �
    �  �  �  �  Set ObjWorkbook = ObjExcelAppl.WorkBooks
    �  �  �  �  ObjWorkbook.Open StrFileName
    �
    �  �  On Error Resume Next
    �  �  ObjExcelAppl.ActiveWorkbook.Save
    �  �  If Err.Number = 1004 Then
    �  �  �  �  Msgbox �Excelfile is already open!�
    �  �  �  �  Exit Sub
    �  �  End If
    �  �  On Error GoTo 0
    �
    �  �  ObjExcelAppl.Worksheets(1).Activate
    �  �  Set ObjWorksheet = ObjExcelAppl.Worksheets(1)
    �
    �  �  �  �  Process_Sheet
    �  �  ObjExcelAppl.ActiveWorkbook.Save
    �  �  ObjExcelAppl.DisplayAlerts = True
    �  �  ObjExcelAppl.ActiveWorkbook.Close(True)
    �
    �  �  End If
    �
    End Sub
    �
    Function Process_Sheet()
    �
    �  �  Dim i
    �  �  If Is_Correct_Sheet() Then
    �
    �  �  i = 2
    �
    �  �  Do While ObjWorksheet.Cells(i, 2).Value <> Empty
    �  �  �  �  Process_Row(i)
    �  �  �  �  i = i + 1
    �  �  �  �  Loop
    �
    �  �  Else
    �  �  Msgbox �Wrong Excel sheet!�
    �  �  End If
    �
    End Function
    �
    Function Is_Correct_Sheet()
    �
    �  �  Dim c � column number
    �  �  Is_Correct_Sheet = False
    �  �  c = 1
    �
    �  �  Do While ObjWorksheet.Cells(1, c).Value <> ��
    �
    �  �  �  �  Select case ObjWorksheet.Cells(1, c).Value
    �  �  �  �  �  �  case �COL1� cCol1 = c
    �  �  �  �  �  �  case �COL2� cCol2 = c
    �  �  End Select
    �
    �  �  �  �  c = c + 1
    �
    �  �  Loop
    �
    �  �  If ( cCol1 <> 0 And cCol2 <> 0 ) Then
    �  �  �  �  Correct_Sheet = true
    �  �  End If
    �
    End Function
    �
    Function Process_Row(ByVal row)
    �
    �  �  c1 = CStr(ObjWorksheet.Cells(row, cCol1).Value)
    �  �  c2 = CStr(ObjWorksheet.Cells(row, cCol2).Value)
    �
    � autECLSession.autECLOIA.WaitForAppAvailable
    �  �
    �  � autECLSession.autECLOIA.WaitForInputReady
    �  � autECLSession.autECLPS.SendKeys "[pf7]"
    �  �
    �  � autECLSession.autECLPS.WaitForAttrib 4,10,"00","3c",3,10000
    �  � autECLSession.autECLPS.WaitForCursor 4,11,10000
    �  � autECLSession.autECLOIA.WaitForAppAvailable
    �  �  autECLSession.autECLPS.SetCursorPos 09,034
    �
    �  �  autECLSession.autECLOIA.WaitForInputReady
    �  �  autECLSession.autECLPS.SendKeys c1
    �  �  autECLSession.autECLPS.SendKeys �[field+]�
    �  �  autECLSession.autECLOIA.WaitForInputReady
    �  �  autECLSession.autECLPS.SendKeys �[enter]�
    �  �  autECLSession.autECLOIA.WaitForAppAvailable
    �  �  �
    end Function
    Thanks,
    Nikhil



-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------

-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------