Jump to content

launching excel from VB file


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 post
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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...