Open Excel Sheet in Vb.net

Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: Apr 2007
Posts: 5
Reputation: anuragNet is an unknown quantity at this point 
Solved Threads: 0
anuragNet anuragNet is offline Offline
Newbie Poster

Open Excel Sheet in Vb.net

 
0
  #1
Apr 23rd, 2007

Hi,
I have an excel file,having lot or micros, connecting to database, doing some complex calculation..inshot that excel file is itself an application.
Now I want to open that excel in VB.net form, on button click. I prefer to open that excel in vb.net form itself having all the excel tool bar etc, If that is not possible then opening in separate window using excel will also solve my purpose (coz when we open in excel it self we will get all the toolbar option etc automatically)
Please Help
Anurag
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 5
Reputation: anuragNet is an unknown quantity at this point 
Solved Threads: 0
anuragNet anuragNet is offline Offline
Newbie Poster

Re: Open Excel Sheet in Vb.net

 
0
  #2
Apr 24th, 2007
No reply from any one here ..but i found the solution from other sources..

To open in vb form :
1) Add com component "Microsoft Web browser" [by right click on toolbox select add/remove item]

2) You will get a new tool "Microsoft Web Browser"

3) Drag control to your form

4) Write this line on some button click or form load
  1. AxWebBrowser1.Navigate("C:\test1.xls")

However opening file in form using webbrowser is giving me some problem as my excel sheet is having VBA code, but for normal excel file it will work.

Alternate way is, open in separate window using excel:
Method 1=>
Imports System.Diagnostics
Dim ps As New ProcessStartInfo
ps.UseShellExecute = True
ps.FileName = "C:\test1.xls"
Process.Start(ps)

Method 2=>
Add Microsoft excel 10.0 as reference

Imports Excel.WorkbookClass
Imports Excel.WorksheetClass
Imports Excel.ApplicationClass

Dim xlsApp As Excel.ApplicationClass
Dim xlsWB As Excel.WorkbookClass
Dim xlsSheet As Excel.WorksheetClass
xlsApp = New Excel.ApplicationClass
xlsApp.Visible = True
xlsWB = xlsApp.Workbooks.Open("C:\test1.xls")

Enjoy!!
anurag_shr
Last edited by anuragNet; Apr 24th, 2007 at 11:14 pm.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC