1

I am looking for a way to open and populate a new sheet while population the sheet from a file.xml.

Any ideas?

Thanks

2
  • possible duplicate of declare/open excel file in vb.net Commented Oct 12, 2011 at 2:19
  • @Ken White I am not opening a .xls or .xlsx workbook just a sheet that populates from a .XML file. I tried that with the .xml file and it didn't work. Commented Oct 12, 2011 at 2:25

2 Answers 2

4
  1. Include a reference to 'Microsoft.Office.Interop.Excel' in your project
  2. Then do something like this:
Imports Microsoft.Office.Interop.Excel
Public Class ReadExcel
    Public Sub OpenDoc(ByVal Filename As String)
        Dim excelApp As New Microsoft.Office.Interop.Excel.Application
        excelApp.Workbooks.OpenXML(Filename)
        ' do something here...
    End Sub
End Class
Sign up to request clarification or add additional context in comments.

1 Comment

I tried this already and this opens a brand new workbook. Looking from something that will open a new sheet in the current active workbook.
1

In addition to what Derek Tomes has answered, you can specify the loading options for the openXML method.

  • xlXmlLoadImportToList = 2
  • xlXmlLoadMapXml = 3
  • xlXmlLoadOpenXml = 1
  • xlXmlLoadPromptUser = 0

You may use xlXmlLoadImportToList to open a new workbook with the xml data you want to load or you may use xlXmlLoadOpenXml to open the xml file itself in excel.

you can hide the alerts with the DisplayAlerts property set to false when loading your xml then just set it to true afterwards.

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.