vbscript语法错误保存excel文件

时间:2016-08-25 07:27:52

标签: vbscript

我的代码在vb脚本中。存储过程的结果保存在excel中。我得到的错误就是

TITLE:ActiveX脚本任务

Error Code: 0
Error Source= Microsoft VBScript compilation error
Error Description: Syntax error
Error on Line 97

-----------------这是代码请帮助..

Dim oFSOExcelFile

Set oFSOExcelFile= CreateObject("Scripting.FileSystemObject")
Dim workSheet,sFileName
Dim iRow,headingRow

'Create the Excel workbook
On error Resume Next
Set oXLIDRenewal = CreateObject("Excel.Application")
oXLIDRenewal.Visible=True
    With oXLIDRenewal
        'Make sure there is no minimized window.
        .Application.Visible = False
        .Application.DisplayAlerts = False
            End With    

If not rstRev.EOF then 
'Name of the excel File to import to.

sFileName=''D:\packages\Rev&CPExcel\Rev'' &iday &''-''&imonth ''-''&iyear &''.xls''

'Delete the Excel File if it already exists.
If oFSOExcelFile.FileExists(sFileName) Then
On Error Resume Next
            oFSOExcelFile.DeleteFile(sFileName)
        End If

1 个答案:

答案 0 :(得分:0)

sFileName=''D:\packages\Rev&CPExcel\Rev'' &iday &''-''&imonth ''-''&iyear &''.xls''

使用错误的引号并且缺少至少一个&amp ;.所以试试:

sFileName = "D:\packages\Rev&CPExcel\Rev" & iday & "-" & imonth & "-" & iyear & ".xls"

仔细检查..\Rev&CPExcel\..