Import XML file stopped working after moving to Excel 2007

djanu

Board Regular
Joined
Oct 30, 2006
Messages
55
Hi,

My Excel worksheet to import xml file was working in Excel 2003, but when I moved to Excel 2007 I started getting this exception:

Run-time error '9':
Subscript out of range

This is what I'm using:

======
Private Sub btn_importPROD_Click()

'1. UNZIP - This part will unzip .ear file to temp folder

Dim PathWinZip As String, FolderName As String
Dim ShellStr As String, strDate As String, Path As String
Dim FileNameZip As Variant, FSO As Object
PathWinZip = "C:\program files\winzip\"
If Dir(PathWinZip & "winzip32.exe") = "" Then
MsgBox "Please find your copy of winzip32.exe and try again"
Exit Sub
End If
FolderName = "C:\TempZip\"
FileNameZip = Application.GetOpenFilename(fileFilter:="Zip Files, *.ear")
If FileNameZip = False Then
Else
ShellStr = PathWinZip & "Winzip32 -min -e" _
& " " & Chr(34) & FileNameZip & Chr(34) _
& " " & Chr(34) & FolderName & Chr(34)
ShellAndWait ShellStr, vbHide
End If

'2. IMPORT XML - This part will import .xml file to Excel

With Sheets("Temp").Range("A1").CurrentRegion
ActiveWorkbook.XmlImport URL:="C:\TempZip\ABC.xml", ImportMap:=Nothing, _
Overwrite:=True, Destination:=Sheets("Temp").Range("A1")
Sheets("Temp").ListObjects("List1").Unlist
End With
======


When I get error and click on Debug it points to this:

Sheets("Temp").ListObjects("List1").Unlist

Any ideas why this worked fine in Excel 2003 and does not work in Excel 2007?
Any suggestions how to fix the issue?

Thank you,
djanu
 

Some videos you may like

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Watch MrExcel Video

Forum statistics

Threads
1,114,653
Messages
5,549,212
Members
410,905
Latest member
Extjel
Top