1

I'm trying to import an XML file into Excel using the Workbooks.OpenXML to load data through VBA. Two questions:

  1. Can this method be called by Excel for Mac?
  2. The second argument is an XSL stylesheet. I have tried pointing to the .xsl I have created that makes the XML flat, but I get Run-time error '5'. Is there a working example I can refer to to determine what I'm doing wrong?

Here is the working example:

Application.Workbooks.OpenXML _
Filename:="C:\Users\eric\Desktop\08D006606_251011_092651.uddf", _
LoadOption:=xlXmlLoadImportToList 

This code throws the following error: Run-time error '5', Invalid procedure call or argument

Dim styleSheet as Variant
styleSheet = "C:\Users\eric\Desktop\XPD.xsl"
Application.Workbooks.OpenXML _
Filename:="C:\Users\eric\Desktop\08D006606_251011_092651.uddf", _
Stylesheets:=styleSheet, _
LoadOption:=xlXmlLoadImportToList 
7
  • Would be useful to show exactly what you tried (a small be representative sample) Commented Oct 30 at 7:44
  • You need to use the transformNode method. Check this link, but not sure if it works with Excel on MAC zetcode.com/vbscript/dom-msxml-transformnode Commented Oct 30 at 7:48
  • @TimWilliams - Updated the description with working/non working example. Thank you for your assistance Commented Oct 30 at 12:33
  • @Haluk - msxml is a .Net component. My primary goal is to make something universal that can be used on both Windows and Mac based Excel editions. Also the example you provided is vbscript, not vba. Are the two interchangeable? Commented Oct 30 at 12:35
  • @eric - You can use that VBScript as is in VBA. By the way; Stylesheets is not a string, it is a variant type parameter. Commented Oct 30 at 16:35

1 Answer 1

0

So, letting a friend try my code on his Mac, without the xsl stylesheet parameter, he got this error
Run-time error '2004'
Method 'OpenXML' of object 'Workbooks' failed.

Which answers my #1 question: importing xml into an Excel for Mac via VBA is not possible.

Thanks for the contributions @timwilliams and @Haluk.
I will start exploring options like Power Query.

Sign up to request clarification or add additional context in comments.

2 Comments

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.