第255行中的ActiveXscript预期语句错误

时间:2016-10-24 10:57:01

标签: vbscript

我写了一个VBscript,我得到了VBScript编译错误"预期声明"第216行的错误。 我已经看到了这个错误的一些示例,但他们没有帮助我。

这是我的代码:

Function Main()
    Dim REGroupSBUOps
    Dim DandBSBUOps
    Dim WestSBUOps
    Dim Tristate_Central_EastSBUOps
    Dim EastSBUOps
    Dim UKSBUOps
    Dim PearsonSBUOps

    Dim oDBCon
    Set oDBCon = CreateObject("ADODB.Connection")

    Set REGroupSBUOps = CreateObject("ADODB.Recordset")
    Set DandBSBUOps = CreateObject("ADODB.Recordset")
    Set WestSBUOps = CreateObject("ADODB.Recordset")
    Set Tristate_Central_EastSBUOps =CreateObject("ADODB.Recordset")
    Set EastSBUOps =CreateObject("ADODB.Recordset")
    Set UKSBUOps =CreateObject("ADODB.Recordset")
    Set PearsonSBUOps= CreateObject("ADODB.Recordset")


    With oDBCon
        .ConnectionString = "Provider=MSDASQL; Driver={SQLServer};
        Server=(servername); DataBase=(database_name;
        User Id=(user_id); Password=(password)"
        .Open
    End With

    Dim strREGroupSBUOps
    Dim strDandBSBUOps
    Dim strWestSBUOps
    Dim strTristate_Central_EastSBUOps
    Dim strEastSBUOps
    Dim strUKSBUOps
    Dim strPearsonSBUOps

    strTristate_Central_EastSBUOps ="sp_CPVarianceOpsReport 1"
    Set Tristate_Central_EastSBUOps = oDBCon.Execute (strTristate_Central_EastSBUOps)

    strUKSBUOps ="sp_CPVarianceOpsReport 2"
    Set UKSBUOps = oDBCon.Execute(strUKSBUOps)

    strWestSBUOps ="sp_CPVarianceOpsReport 3"
    Set WestSBUOps = oDBCon.Execute(strWestSBUOps)


    strEastSBUOps ="sp_CPVarianceOpsReport 4"
    Set EastSBUOps = oDBCon.Execute(strEastSBUOps)

    strDandBSBUOps ="sp_CPVarianceOpsReport 5"
    Set DandBSBUOps = oDBCon.Execute(strDandBSBUOps)

    strREGroupSBUOps ="sp_CPVarianceOpsReport 6"
    Set REGroupSBUOps = oDBCon.Execute(strREGroupSBUOps)

    strPearsonSBUOps ="sp_CPVarianceOpsReport 7"
    Set PearsonSBUOps = oDBCon.Execute(strPearsonSBUOps)

    Dim iDay, iMonth, iYear
    iDay    = Day   (Date())
    iMonth  = Month (Date())
    iYear   = Year  (Date())

    Dim arr()
    ReDim arr(6)
    arr(0)= "REGroupSBUOps"
    arr(1)= "DandBSBUOps"
    arr(2)= "Tristate/Central/EastSBUOps"
    arr(3)= "WestSBUOps"
    arr(4)= "EastSBUOps"
    arr(5)= "UKSBUOps"
    Dim i
    For i=0 To 5
        If Not (arr(i).EOF) Then
            Dim oFSOExcelFile
            On Error Resume Next
            Set oFSOExcelFile= CreateObject("Scripting.FileSystemObject")
            Dim  workSheet,sFilename1
            Dim iRow, headingRow
            On Error Resume Next
            Set objExcel= CreateObject("Excel.Application")
            objExcel.Visible = True
            With objExcel
                .Application.Visible = False
                .Application.DisplayAlerts = False
            End With

            sFileName1="\\CTSC00579895801\ime\MailReports\" +arr(i)+ ".xls"
            If oFSOExcelFile.FileExists(sFileName1)then
                On Error Resume Next
                oFSOExcelFile.DeleteFiles(sFileName1)
            End If
            With objExcel
                .Workbooks.Add
                Set workSheet= .Sheets("Sheets1")
                workSheet.Select
                iRowData=0
                flag=0
                While Not (arr(i).EOF)
                    If iRowData=0 then
                        headingRow = iRowData + 1
                    Else
                        headingRow = iRowData - 1
                    End If

                    If flag=0 Then
                        .Cells(headingRow, 1).Value = "BU"
                        .Cells(headingRow, 1).Font.Bold = "true"
                        .Cells(headingRow, 1).Interior.Color=RGB(255,198,179)
                        .Cells(headingRow, 1).ColumnWidth = 10

                        .Cells(headingRow, 2).Value = "SBU"
                        .Cells(headingRow, 2).Font.Bold = "true"
                        .Cells(headingRow, 2).Interior.Color=RGB(255,198,179)
                        .Cells(headingRow, 2).ColumnWidth = 10

                        .Cells(headingRow, 3).Value ="ParentCustomerName "
                        .Cells(headingRow,  3).Font.Bold = "true"
                        .Cells(headingRow, 3).Interior.Color=RGB(255,198,179)
                        .Cells(headingRow,  3).ColumnWidth = 50

                        .Cells(headingRow, 4).Value = "CMFlash"
                        .Cells(headingRow, 4).Font.Bold = "true"
                        .Cells(headingRow, 4).Interior.Color=RGB(255,198,179)
                        .Cells(headingRow, 4).ColumnWidth = 10

                        .Cells(headingRow, 5).Value ="CMforecast"
                        .Cells(headingRow, 5).Font.Bold = "true"
                        .Cells(headingRow, 5).Interior.Color=RGB(255,198,179)
                        .Cells(headingRow, 5).ColumnWidth = 10

                        .Cells(headingRow, 6).Value ="flashvsforecastvariance"
                        .Cells(headingRow, 6).Font.Bold = "true"
                        .Cells(headingRow, 6).Interior.Color=RGB(255,198,179)
                        .Cells(headingRow, 6).ColumnWidth = 25

                        .Cells(headingRow, 7).Value ="ReasonforCPVSFcstVariance"
                        .Cells(headingRow, 7).Font.Bold = "true"
                        .Cells(headingRow, 7).Interior.Color=RGB(255,198,179)
                        .Cells(headingRow, 7).ColumnWidth = 75

                        .Cells(headingRow, 8).Value ="ExpectedinFinal"
                        .Cells(headingRow, 8).Font.Bold = "true"
                        .Cells(headingRow, 8).Interior.Color=RGB(255,198,179)
                        .Cells(headingRow, 8).ColumnWidth = 20

                        .Cells(headingRow, 9).Value ="FinalvsFlash"
                        .Cells(headingRow, 9).Font.Bold = "true"
                        .Cells(headingRow, 9).Interior.Color=RGB(255,198,179)
                        .Cells(headingRow, 9).ColumnWidth = 10

                        .Cells(headingRow, 10).Value ="UpdatedBy"
                        .Cells(headingRow, 10).Font.Bold = "true"
                        .Cells(headingRow, 10).Interior.Color=RGB(255,198,179)
                        .Cells(headingRow, 10).ColumnWidth = 30

                        .Cells(headingRow, 11).Value ="Updateddate"
                        .Cells(headingRow, 11).Font.Bold = "true"
                        .Cells(headingRow, 11).Interior.Color=RGB(255,198,179)
                        .Cells(headingRow, 11).ColumnWidth = 10

                        flag=1
                    End If

                    iRowData=headingRow+1

                    .Cells(iRowData, 1).Value = (arr(i) ("BU"))
                    .Cells(iRowData, 1).ColumnWidth = 10

                    .Cells(iRowData, 2).Value = (arr(i) ("SBU"))
                    .Cells(iRowData, 2).ColumnWidth = 10

                    .Cells(iRowData, 3).Value =(arr(i) ("ParentCustomerName "))
                    .Cells(iRowData, 3).ColumnWidth =20

                    .Cells(iRowData, 4).Value = (arr(i) ("CMFlash"))
                    .Cells(iRowData, 4).ColumnWidth = 10

                    .Cells(iRowData, 5).Value = (arr(i) ("CMforecast"))
                    .Cells(iRowData, 5).ColumnWidth = 10

                    .Cells(iRowData, 6).Value =(arr(i) ("flashvsforecastvariance"))
                    .Cells(iRowData, 6).ColumnWidth = 5

                    .Cells(iRowData, 7).Value =(arr(i) ("ReasonforCPVSFcstVariance"))
                    .Cells(iRowData, 7).ColumnWidth = 5

                    .Cells(iRowData, 8).Value = (arr(i) ("ExpectedinFinal"))
                    .Cells(iRowData, 8).ColumnWidth = 5

                    .Cells(iRowData, 9).Value = (arr(i) ("FinalvsFlash"))
                    .Cells(iRowData, 9).ColumnWidth = 10

                    .Cells(iRowData, 10).Value = (arr(i) ("UpdatedBy"))
                    .Cells(iRowData, 10).ColumnWidth = 20

                    .Cells(iRowData, 11).Value = (arr(i) ("Updateddate"))
                    .Cells(iRowData, 11).ColumnWidth = 20

                    iRowData = iRowData  + 1

                    arr(i).MoveNext
                Wend

                .ActiveWorkbook.SaveAs sFileName1
                .ActiveWorkbook.Close
            End With

            Set oFSOExcelFile = Nothing
            Set objExcel = Nothing
            objExcel.Quit
        End If

        Exit For

    Main = DTSTaskExecResult_Success '<-- error occurs here
End Function

错误显示在Main = DTSTaskExecResult_Success

0 个答案:

没有答案