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

Need Help



   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(�cel.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(�cel.Application�   � � StrFileName = ObjExcelAppl.GetOpenFilename _
   � � � � (�crosoft 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 �celfile 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 �ong Excel sheet!�  � � End If
   �   End Function
   �   Function Is_Correct_Sheet()
   �   � � Dim c �olumn number
   � � Is_Correct_Sheet = False
   � � c = 1
   �   � � Do While ObjWorksheet.Cells(1, c).Value <> �   �   � � � � Select case ObjWorksheet.Cells(1, c).Value
   � � � � � � case �L1�Col1 = c
   � � � � � � case �L2�Col2 = 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 �ield+]�  � � autECLSession.autECLOIA.WaitForInputReady
   � � autECLSession.autECLPS.SendKeys �nter]�  � � 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
-----------------------------------------------------------------------