Runninig macro in Excel  
Author Message
Yaroslav Ivanov





PostPosted: Visual C++ General, Runninig macro in Excel Top

Hello! Please, forgive me for my poor English.
I have a macro in excel which is saved in 'PERSOANL.XLS' to be able to use it in any workbook.
When I run Excel manually, everything works fine.
Now I need to Run this macro using my MFC application.
Here is a code

Excel::ApplicationClass ^xlApp = gcnew Excel::ApplicationClass();
xlApp->Visible = true;
Excel::Workbook ^pBook = xlApp->Workbooks->Open(path, other params...);
xlApp->Run(_T("PERSONAL.XLS!Conv"), other params...);

Excel starts, opens a file, but application throws the error that 'PERSONAL.XLS' was not found.
When I try to run a macro manually (without closing the opened workbook), I can't find it, 'PERSONAL.XLS' really doesn't exist. If I try to create a macro and save it to 'PERSONAL.XLS', Excel gives an error that the operation is not possible.

Also I tried like this:

Excel::Workbooks ^pBooks = xlApp->Workbooks;

Excel::_Workbook ^pBook = pBooks->Open(path, other params...);

It didn't help also...
When I stop Excel and run it again manually, everything becomes fine again.
Can you help me



Visual C++6  
 
 
Yaroslav Ivanov





PostPosted: Visual C++ General, Runninig macro in Excel Top

The solution is very simple: to open PERSONAL.XLS before opening required workbook