Can not use Excel file when actxserver is used in standalone application

7 views (last 30 days)
I have developed with MATLAB a standalone application which imports data, processes data and exports results. The importing and exporting are from and to .csv files handled by actxserver in the back. When the standalone application is running, if users try to open new file with MS Excel, the application might crash, no matter the newly openned file is the same as the files handled by MATLAB application or not. It doesn't happen all the time, but very frenquently. Any hint is appreciated.

Answers (1)

Image Analyst
Image Analyst on 23 Jul 2014
Is the CSV reading and writing done by csvread() and csvwrite() and you're only using Excel to open up the csv in Excel for the user to view? Or are you using Excel when reading and writing the files also? Sounds like it's the latter. Since they're just simple csv files, why not try to use csvwrite() instead of controlling Excel via ActiveX to create them?
  10 Comments
Image Analyst
Image Analyst on 28 Jul 2014
You can ask ActiveX for the workbook names. Then, if you find it, set the active workbook to that one. If you don't (like the user manually closed your workbook), then alert the user.
Eric
Eric on 28 Jul 2014
Edited: Eric on 28 Jul 2014
Your code is getting confused because you're using shortcuts like ActiveWorkbook and ActiveSheet. If you try to work in Excel while the code is doing this, you'll be changing which workbooks and sheets are active. You can interface to Excel and work in other workbooks simultaneously if you avoid these shortcuts. That means your code needs to keep track of workbooks, sheets, etc. by their names. This is a bit of a hassle but allows you to work on multiple files simultaneously.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!