• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Launching Excel from VB.Net - Figured it out.

drebo

Diamond Member
So, I've got a project to do. I query a database based on some parameters entered by the user, display the data in a DataGridView, let the user play with it a bit, he selects data and those selected rows go into another DataGridView where the user can play with it some more, user repeats the search and select process until he's done.

Now, the user clicks the "Export" button. Excel template file loads, fields are populated based on selected rows.

Now, here's the tricky part. I need this programmatically modified Excel workbook to launch into Excel. I can save the workbook. I can launch a web browser with the web-generated version. I can Print Preview the workbook.

But, I cannot for the life of me get the workbook to open in Excel.

Can anyone tell me which method I need to use to launch Excel with this workbook pre-loaded? I would love you to bits and pieces!

Edit: Figured it out... excel.Visible = true... I swear... Arg!
 
Actually, not making it visible to begin with will speed up any processing you do, because it doesn't have to immediately redraw your results.

And you should use CreateObject() (new Excel.Applicaton) and not GetObject() [or equivalent] so that way you can manage all the instances that your program uses, and simply address workbook 0 of that application instance. Plus you can just make your own instance of it invisible, because the user may have other Excel docs he wants open. Otherwise, you are just complicating it for yourself.
 
xtknight is right, make it invisible. There is a huge difference in processing speed that be gained.

techfuzz
 
It is invisible while I'm doing work in it. However, it needs to be visible at the end (user has some manual information needed to be entered).
 
Back
Top