实时错误462远程服务器不存在或不能使用
请教一个问题,我看论坛里也有同样的问题,他们解决了,但是没有写解决方法,问了他们也没有回复,所以想请教一下大家,问题如下:
Private Sub Cmd_change_Click()
Dim cstrfilename As String
Dim cstrfilelist(0 To 100) As String
On Error GoTo Errmess
For i = 1 To FileList.ListCount
cstrfilelist(i - 1) = FileList.List(i - 1)
Next i
If FileList.ListCount <= 0 Then
MsgBox "文件夹为空,请从新选择! ", vbOKOnly, "系统提示 "
Else
For j = 1 To FileList.ListCount
Dim xls As Excel.Application
Dim xlsBook As Excel.Workbook
Dim xlsSheet As Excel.Worksheet
Dim xlsBook2 As Excel.Workbook
Dim xlSheet2 As Excel.Worksheet
Set xls = CreateObject( "Excel.Application ")
xls.Workbooks.Add
Set xlsBook = xls.Workbooks.Add
Set xlsSheet = xlsBook.Sheets( "Sheet1 ")
Set xlsBook2 = xls.Workbooks.Open(FileDir.Path + "\ " + cstrfilelist(j - 1))
Set xlssheet2 = xlsBook2.Sheets(Left(cstrfilelist(j - 1), Len(cstrfilelist(j - 1)) - 4))
xlsBook2.Sheets(1).Select
xlsBook2.Sheets(1).Copy Before:=xlsBook.Sheets( "Sheet1 ")
Set xlssheet2 = Nothing
xlsBook2.Close
Set xlsBook2 = Nothing
Kill FileDir.Path + "\ " + cstrfilelist(j - 1)
xls.DisplayAlerts = False
ActiveWorkbook.SaveAs FileDir.Path + cstrfilelist(j - 1) '保存文件
Set xlsSheet = Nothing
xlsBook.Close
Set xlsBook = Nothing
xls.Quit
Set xls = Nothing
KillProcess
Next j
MsgBox "格式转换完成! "
End If
Exit Sub
errmess:
MsgBox err.Description
KillProcess
End Sub
我两次连续执行,第一次没有问题,第二次出现 "实时错误462远程服务器不存在或不能使用 " ,我点调试光标在ActiveWorkbook.SaveAs FileDir.Path + cstrfilelist(j - 1) 一行,不知道是什么问题,请斑竹帮我看看,谢谢
[解决办法]
Kill FileDir.Path + [color=#0000FF]"\ " + cstrfilelist(j - 1)
[/color]
xls.DisplayAlerts = False
ActiveWorkbook.SaveAs FileDir.Path + cstrfilelist(j - 1)
'你'为什么相同的路径及文件名,一个中间加"\" 一个中间不加 "\"
[解决办法]
Kill FileDir.Path + [color=#FF0000]" \ " + cstrfilelist(j - 1) [/color]
xls.DisplayAlerts = False
ActiveWorkbook.SaveAs FileDir.Path + cstrfilelist(j - 1)
'你'为什么相同的路径及文件名,一个中间加"\" 一个中间不加 "\"
[解决办法]
晕.中间那个 "\" 让他显示红色为什么不行/
再来一次:
Kill FileDir.Path + ]" \ " ]+ cstrfilelist(j - 1)
xls.DisplayAlerts = False
ActiveWorkbook.SaveAs FileDir.Path + cstrfilelist(j - 1)
'你'为什么相同的路径及文件名,一个中间加"\" 一个中间不加 "\"