Importing data into excel using VB 2005EE

Hi everyone,

I've been trying to write a small app which will open an xml file & read data from it, pasting that data into an excel worksheet & save it afterwards.

I will be using the split function to parse the xml file so that I only copy in the numbers I need & ignore the tags. I was going to originally use a VBA macro but thought it better to get my teeth into VBEE instead.

One of the early problems though is actually taking a selection from a combo box (say 1234) & using that to then open the corresponding xml file for 1234 & getting the data to import into excel.

I've read up a lot recently but can't find a definitive way to get VBEE to open the Excel file, I've tried various code snippets but they all run into problems such as Excel not being part of the namepsace etc (I've added the reference for excel 2003 so it should allow me but doesn't)

What I'd love to know for sure is:

How can I get VBEE to open & displat my Excel file? By that I mean which imports do I need & then how to just open & display my file, 1234.xls?

Thanks in advance for any assistance

[1170 byte] By [John_Q_Public] at [2007-12-24]
# 1
i found a three ways to open xml files :
1) by COM object : http://www.c-sharpcorner.com/UploadFile/mgold/HowtoOepnandReadanExcelSpreadsheetinaListViewin.NET11282005034134AM/HowtoOepnandReadanExcelSpreadsheetinaListViewin.NET.aspx
2) by inteloping excel : http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=385737&SiteId=1
3)by oledb object : http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=516794&SiteId=1
wnuku at 2007-8-31 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 2

Thanks for that wnuku, I think the middle link was the clincher (turns out it was a case of simply using process.start, d'oh!)

I'd like to see if there's a possibility my nexy & final qeury might have an answer available:

...I've decided to get teh values I need from the xml file using xmlreader, which is a hell of a lot better than trying to setup a complicated loop of split functions, but I'm stuck at a specific part :

The xmlreader is working fine & showing me the numbers I need from the source xml file, however to progress I need to find a way of doing the following:

Take first returned value & store in List 1

Take second returned value & store in List 2

Repeat until lists 1 & 2 are complete.

Now, there's approx 5000 different values for each list, i.e. xmlreader returns a total of approx 10000 values, I need to find a way to end up with 2 complete lists which I can then paste into my excel file. Some sort of function which alternates the storage location would certainly help, but as yet my reading has turned up nothing. I suppose even a function which takes the first value (1 = odd) then the second (2 = even) & alternates depending on whether it's an odd or even number of returned values (until the endpoint, which I can define) would do.

As yet, though, I'm stumped

TIA

John_Q_Public at 2007-8-31 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 3

How To Automate Microsoft Excel from Visual Basic

http://support.microsoft.com/kb/219151/

This will get you going - it adds a sheet, sets some range properties... etc and changing some font properties such as bold.

spotty at 2007-8-31 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...