[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Need Help
Hi,
Most likely issue is with data type mismatch, if possible can you send the error log to debug through
--
Chamara Withanachchi
Sri Lanka
M : +94 77 7604010
Sent from my iPhone
> On Jan 22, 2016, at 00:52, Nikhil Rustagi <nik.rust@xxxxxxxxx> 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
-----------------------------------------------------------------------