indupriya9
Programmer
Hi Everyone
I have tried to write a macro that imports XML documents in a specific directory into Excel 2003. The file search part is being handled correctly. But the import of XML part is where it errors out. The error is "Object Required"
Here is the code that I have written.
Can anyone out there help me resolve this problem please?
Thanks in advance
Priya
I have tried to write a macro that imports XML documents in a specific directory into Excel 2003. The file search part is being handled correctly. But the import of XML part is where it errors out. The error is "Object Required"
Here is the code that I have written.
Code:
Sub SImport()
'
' XMLimport Macro
' Macro recorded 24/09/2007 by Priya
'
'
Dim fs As FileSearch, i As Long, filePath As Variant, filenam As Variant, fsObject As Variant, file As Variant
Dim wsh As Worksheet
Dim xmpCustomMap As XmlMap
Set fs = Application.FileSearch
Path = "\\intranet\budgets\project_budgets\"
With fs
.SearchSubFolders = False
.FileType = msoFileTypeAllFiles
.LookIn = "\\intranet\budgets\Project_Budgets\"
.Execute
For Each filePath In .FoundFiles
i = i + 1
Set fsObject = CreateObject("Scripting.FileSystemObject")
Set file = fsObject.GetFile(filePath)
filenam = file.Name
FullName = Path + filenam
MsgBox (FullName)
'Set xmpCustomMap = ActiveWorkbook.XmlMaps("MyFields_Map")
'ActiveWorkbook.XMLimport URL:=FullName, ImportMap:=xmpCustomMap, _
'Overwrite:=False, Destination:=Range("$B$1")
ActiveWorbook.XmlMaps("MyFields_Map").Import FullName, False (Error Line)
.NewSearch
Next filePath
End With
End Sub
Can anyone out there help me resolve this problem please?
Thanks in advance
Priya