Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

.NET Forum


You are currently viewing our .NET Forum as a guest. Please register to participate.
Login



Closed Thread
Open Excel File in Vb.net
Old 04-23-2007, 10:29 PM Open Excel File in Vb.net
Junior Talker

Posts: 4
Name: Anurag Sharma
Trades: 0

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
anuragNet is offline
View Public Profile
 
 
Register now for full access!
Old 04-23-2007, 11:12 PM Re: Open Excel File in Vb.net
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
http://support.microsoft.com/kb/301982
http://support.microsoft.com/kb/302094

There is a couple of links which should get you started. If I recall, you can manipulate spreadsheets fairly easily within vb.net. The easiest task to accomplish what you want would be to open the file directly on a button click.

Furthermore I found this code snippet which might help...

Code:
Dim excel As Microsoft.Office.Interop.Excel.Application

Dim wb As Microsoft.Office.Interop.Excel.Workbook

Try

excel = New Microsoft.Office.Interop.Excel.Application
wb = excel.Workbooks.Open("c:\\test.xls")
excel.Visible = True
wb.Activate()

Catch ex As COMException
MessageBox.Show("Error accessing Excel: " + ex.ToString())

Catch ex As Exception
MessageBox.Show("Error: " + ex.ToString())

End Try
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
View Public Profile
 
Old 04-23-2007, 11:37 PM Re: Open Excel File in Vb.net
Junior Talker

Posts: 4
Name: Anurag Sharma
Trades: 0
Hi,
Thanks for reply. I have already tried this method, its working fine for a simple excel file, but when i am trying to open my excel file having micro and VBA code its not working.
Is there any alternative.
Thanks
Anurag
anuragNet is offline
View Public Profile
 
Old 04-23-2007, 11:39 PM Re: Open Excel File in Vb.net
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
What specific error message are you getting?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
View Public Profile
 
Old 04-23-2007, 11:42 PM Re: Open Excel File in Vb.net
Junior Talker

Posts: 4
Name: Anurag Sharma
Trades: 0
I am not getting any error but it is opening a blank excel sheet.
anuragNet is offline
View Public Profile
 
Old 04-24-2007, 02:55 AM Re: Open Excel File in Vb.net
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,023
Name: Forrest Croce
Location: Seattle, WA
Trades: 0
Can you enumerate ( foreach ) the sheets in the workbook?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
ForrestCroce is offline
View Public Profile Visit ForrestCroce's homepage!
 
Closed Thread     « Reply to Open Excel File in Vb.net
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.60687 seconds with 12 queries