我写了一段EXCEL VBA,在本电脑可以运行,但放到其他电脑无法运行,系统和EXCEL设置都一致。错误提示 400

Dim MyPath, MyName, AWbName
Dim Wb As Workbook, WbN As String
Dim G As Long
Dim Num As Long
Dim BOX As String
Application.ScreenUpdating = False
MyPath = ActiveWorkbook.Path
MyName = Dir(MyPath & "\" & "*.tsv")
AWbName = ActiveWorkbook.Name
Num = 0
Do While MyName <> ""
If MyName <> AWbName Then
Sheets.Add After:=Sheets(1)
Sheets(2).Select
'已测试,是这里开始无法运行,但找不到原因,求帮助
With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & MyName, Destination:=Range("$A$1"))
.Name = ""
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 65001
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End If
MyName = Dir
Loop

第1个回答  2014-12-12
可能是路径里面有空格什么的,别放在桌面运行了,放在一个其他盘里面运行一下试试追问

谢谢帮忙,但不是空格或者或者路径错误的问题,刚刚已解决。
是电脑存在默认路径,将mypath放上去後,其他电脑都可以运行了

本回答被网友采纳
相似回答