Solved

How to track my Excel 2007 appliction is open.

Posted on 2013-05-13
2
279 Views
Last Modified: 2013-05-17
Hi, I am running vb.net application and open the excel file. Data are updated accordingly from vb.net to excel. I am managed this part.

I did use this function code to track my excel is open or not :-

Private Function TestEXCEL() as Boolean
dim fs as filestream
try
      fs = File.Open(xlpath, FileMode.Open, FileAccess.Read, FileShare.None)
     TestEXCEL = False
Catch ex as Exception
     TestEXCEL = True
End try

While after i do force close my excel file, my code try to reopen the file by coding i do face the error message as follows at this line

xlApp = New Excel.Application
xlworkbook = xlApp.Workbooks.Open(xlpath)   <-- Error pointed over here

Error message : COMException was unhandled
Excel cannnot open the file 'Tri_data.xlsx' because teh file format or file extension in not valid. Verif that the file has not been corrupted and that the file extension matches the format of the file.
0
Comment
Question by:TITO2009
2 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39161029
What happens if you change

fs = File.Open(xlpath, FileMode.Open, FileAccess.Read, FileShare.None)

to

fs = File.Open(xlpath, FileMode.Open, FileAccess.Write,  FileShare.None)


Also add a

fs.Close

after the =False line.
0
 

Author Comment

by:TITO2009
ID: 39170305
Hi I am away from office, by tomorrow l am to cheek out and reply. sorry for delay .Thank you .
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now