0

I have a piece of code where I am opening an XML file from VB NET console app, than I Save As this file as XLSX file

Dim oxl As Excel.Application
Dim owbs As Excel.Workbooks
Dim owb As Excel.Workbook
Dim osheets As Excel.Worksheets
Dim osheet As Excel.Worksheet

oxl = CreateObject("Excel.Application")
oxl.DisplayAlerts = True
oxl.Visible = True
owb = oxl.Workbooks.Open(file)
Dim newfile As String = Replace(file, ".xml", ".xlsx")
owb.SaveAs(newfile)
owb.Close()
oxl.Quit()

When I manualy open Excel 365, then I choose "Open file", I choose an XML file, Excel ask me, if I want to open it as an XML table and if I choose yes, table has another format, is coloured and headers in table are correct. When I open XML from my code, table isn't coloured, nevermind, but I have wrong table headers. Is it possible somehow open XML file as XML table from oxl.Workbooks.Open(file)?

I couldn't find a solution to my problem anywhere.

3
  • Show the output you get and the desired output. It's unclear what you are asking Commented Sep 22 at 13:58
  • 1
    Is it possible somehow open XML file as XML table from oxl.Workbooks.Open(file) - by replacing it with oxl.Workbooks.OpenXML(file)? Commented Sep 22 at 14:06
  • @GSerg I tried oxl.Workbooks.OpenXML(file) with same results like oxl.Workbooks.Open(file) Commented Sep 23 at 7:07

1 Answer 1

0

Got it.

owb = oxl.Workbooks.OpenXML(file,, 2)

did the trick.

https://learn.microsoft.com/en-us/office/vba/api/excel.xlxmlloadoption

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

Comments

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.