HighlanderSword

Excel open XML File

9 posts in this topic

Hello,

I'm trying to open an xml file in excel using the code below

 

$oExcel = _Excel_Open()
$oExcel.Workbooks.OpenXML('Filename:="d:\test1.xml"', 'LoadOption:=XlXmlLoadOption.xlXmlLoadImportToList')

 

I get the error message

$oExcel.Workbooks.OpenXML('Filename:="D:\test1.xml"', 'LoadOption:=XlXmlLoadOption.xlXmlLoadImportToList')
$oExcel.Workbooks^ ERROR.

 

I have searched the forums and have not found any matched on how to open an xml file in Excel .

Below is the Macro code when I record the steps to manually do it in excel, how do I do this using the Excel UDF ?

Workbooks.OpenXML Filename:=  "d:\test1.xml", LoadOption  :=xlXmlLoadImportToList

Share this post


Link to post
Share on other sites



AutoIt does not support named parameters. Needs to be something like this:

; XlXmlLoadOption Enumeration: https://msdn.microsoft.com/en-us/library/ff194637(v=office.14).aspx
Global $xlXmlLoadImportToList = 2 ; Places the contents of the XML data file in an XML table
$oExcel = _Excel_Open()
$oExcel.Workbooks.OpenXML("d:\test1.xml", "", $xlXmlLoadImportToList)

as described here: https://msdn.microsoft.com/en-us/library/ff838643(v=office.14).aspx


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2016-07-20 - Version 1.2.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Gives error

 

"D:\Listing.au3" (12) : ==> The requested action with this object has failed.:
$oExcel.Workbooks.OpenXML("D:\ysb.xlm", "", $xlXmlLoadImportToList)
$oExcel.Workbooks^ ERROR

 

; XlXmlLoadOption Enumeration: https://msdn.microsoft.com/en-us/library/ff194637(v=office.14).aspx
Global $xlXmlLoadImportToList = 2 ; Places the contents of the XML data file in an XML table
$oExcel = _Excel_Open()
$oExcel.Workbooks.OpenXML("D:\ysb.xlm", "", $xlXmlLoadImportToList)

Share this post


Link to post
Share on other sites

Maybe (can't test at the momen):

; XlXmlLoadOption Enumeration: https://msdn.microsoft.com/en-us/library/ff194637(v=office.14).aspx
Global $xlXmlLoadImportToList = 2 ; Places the contents of the XML data file in an XML table
Global $oExcel = _Excel_Open()
Global $oWorkbook = $oExcel.Workbooks.OpenXML("d:\test1.xml", Default, $xlXmlLoadImportToList)

 

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2016-07-20 - Version 1.2.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thank You !!!!!!! that worked !!!!!!!

Share this post


Link to post
Share on other sites

Glad you Like this solution ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2016-07-20 - Version 1.2.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Does it hurt to be that good water? You helped me out to thank you.


Sky

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

[double post]

Edited by SkysLastChance
double post

Sky

Share this post


Link to post
Share on other sites

No, it doesn't hurt :) But it takes ages to become a genius ;)
Understanding Microsofts COM model is not easy, but writing Office UDFs like I did (Word, Excel, Outlook, ExcelChart) helps a lot :D

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2016-07-20 - Version 1.2.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now