因此,这是我需要帮助的代码:
Set oExcel = CreateObject("Excel.Application")
If sPath = "" Then
sPath = fWindowsTemp
End If
If sPath = "" Then
sPath = "C:\"
End If
sArq = Dir(sPath & sNomeArquivo & "????." & sExtensao)
iNumero = 0
While sArq <> ""
If Val(Mid(Replace(sArq, sNomeArquivo, "TEMP"), 5, 4)) >iNumero Then
iNumero = Val(Mid(Replace(sArq, sNomeArquivo, "TEMP"), 5, 4))
End If
sArq = Dir
Wend
If (bSalvarPDF) Then
sArq = Dir(Trim(sPath) & Trim(sNomeArquivo) & "????.PDF")
While sArq <> ""
If Val(Mid(Replace(sArq, sNomeArquivo, "TEMP"), 5, 4)) iNumero Then
iNumero = Val(Mid(Replace(sArq, sNomeArquivo, > "TEMP"), 5, 4))
End If
sArq = Dir
Wend
End If
sArq = Trim(sPath) & sNomeArquivo & Right("0000" & iNumero + 1, 4) & "." & sExtensao
Call MsgBox(sArq, vbOKOnly, "Arquivo")
oFile.CopyFile rst!EXC_Arq, sArq
oExcel.Workbooks.Open sArq
oExcel.Calculation = xlManual
它给我以下错误:
找不到错误1004'file.xlsx'。
我的日志警告该错误在以下行:
oExcel.Workbooks.Open sArq
此外,我的变量sArq
给出以下结果:
C:\DOCUME~1\GAtec\CONFIG~1\Temp\TST 020005.XLS
,有时也.XLSX
我当前的计算机上装有支持.xlsx的Excel 2007
有线索吗?