由于某种原因,以下宏不起作用:
Sub ExtractDataTest()
Dim FilePath$, Row&, Column&, Address$
'change constants & FilePath below to suit
'***************************************
Const FileName$ = "Dxo.xlsx"
Const SheetName$ = "Open"
Const NumRows& = 50
Const NumColumns& = 20
FilePath = ("http://enhanced1.sharepoint.hx.com/teams/")
'***************************************
DoEvents
Application.ScreenUpdating = False
If Dir(FilePath & FileName) = Empty Then
MsgBox "The file " & FileName & " was not found", , "File Doesn't Exist"
Exit Sub
End If
For Row = 1 To NumRows
For Column = 1 To NumColumns
Address = Cells(Row, Column).Address
Cells(Row, Column) = GetData(FilePath, FileName, SheetName, Address)
Columns.AutoFit
Next Column
Next Row
ActiveWindow.DisplayZeros = False
End Sub
Private Function GetData(Path, File, Sheet, Address)
Dim Data$
Data = "'" & Path & "[" & File & "]" & Sheet & "'!" & _
Range(Address).Range("A1").Address(, , xlR1C1)
GetData = ExecuteExcel4Macro(Data)
End Function
我在线收到运行时错误“52”(“错误的文件名或编号”):
If Dir(FilePath & FileName) = Empty Then
有趣的是它确实工作过一次。当位置为“C:\”时,它可以工作并且我没有收到错误。奇怪的东西家伙。
任何帮助将不胜感激。