I’ve come to understand that when Excel is opened via automation it does not by default open its startup items, for example the personal.xls workbook. This is causing a problem for my users who sometimes open Excel via my application and then continue to use it thereafter for their other work.
Unfortunately the instance of Excel opened in this way does not contain their personal macros. They must close Excel and reopen it from outside my application so that their macros are available.
Is there a way to cause Excel to automatically load the personal.xls workbook when starting it through automation? If not, what would be the best way of opening that file, bearing in mind that it should not be visible to the user but remain hidden?
I haven’t found any options to do this when creating the object and opening the application
Excel.Application xlApp = new Excel.Application();
Any advice or links anyone can provide would be most appreciated. I’ve searched and searched for information on this but no one seems to have tried a way around it. I’m using Excel 2007 and .NET 2.0.
It turns out that simply finding and opening the user’s personal.xls (or personal.xlsx for those created in newer versions of Excel) is the answer.
Excel.Application xlApp = new Excel.Application(); string filename = xlApp.StartupPath + "\personal.xls"; xlApp.Workbooks.Open(filename, 0, false, 5, Missing.Value, Missing.Value, false, Missing.Value, Missing.Value, Missing.Value, false, Missing.Value, false, true, false);
The personal.xls workbook opens hidden in the background (as required) and allows full use of all the macros attached to it.
Once I knew what to look for, I found some good information in this post: Excel XLSTART problem with C#/.Net
I don’t know if this is what you are looking for, but I’ve had the same add-on issue in Word. I’ve solved it, but it might not be what you need.
Save the file with automation, then start it with process.
I hope this works.