Jump to content

launching excel from VB file


csuders23

Recommended Posts

i have a project written in VB that creates a comma delimited text file and i was wondering if someone can help me create a function (a button_click action?) that will launch excel and read in the comma delimited file. any help with what this code might look like, or a good source for a tutorial on this would be greatly appreciated. I've looked around the W3 lessons on Vb and haven't found anything, but maybe i'm not looking in the right place. thanks!

Link to comment
Share on other sites

I haven't touched this stuff since 1998 or so, so bear with me. I needed, like you, to automate some processes using, among other things, Excel and I didn't really have any idea where to start. What I did, and what I'd recommend you do, is record a macro of the task that you want to accomplish. Then you can edit that macro to view the code that Microsoft writes and use that code to figure out how to automate the task.For a reference for VBA and Excel, check out this site:http://msdn.microsoft.com/library/?url=/li....asp?frame=true

Link to comment
Share on other sites

I haven't touched this stuff since 1998 or so, so bear with me. I needed, like you, to automate some processes using, among other things, Excel and I didn't really have any idea where to start. What I did, and what I'd recommend you do, is record a macro of the task that you want to accomplish. Then you can edit that macro to view the code that Microsoft writes and use that code to figure out how to automate the task.For a reference for VBA and Excel, check out this site:http://msdn.microsoft.com/library/?url=/li....asp?frame=true
so how would one go about making the call to excel and launching that macro from within VB. how do you declare a new instance of an application from within my code? then how do i make it execute that macro once excel is loaded?
Link to comment
Share on other sites

Like I said, it's been a long time, but a Google search returned this:http://www.activexperts.com/activmonitor/w...msoffice/excel/Basically, in your case, you open up an instance of Excel using something like this:

Dim objExcelSet objExcel = CreateObject("Excel.Application")

And then, rather than executing the macro, you execute the code that the macro writes by copying it and then pasting it into your script. When you're done, close Excel:

objExcel.Quit

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...