M
Mike W
I have an interesting and perplexing problem with office automation with C#,
..Net Windows Application. I'm trying to connecti to an existing copy of Excel
I followed the instructions in http://support.microsoft.com/kb/316126
Excel.Application oExcelApp;
this.Activate();
oExcelApp =
(Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
MessageBox.Show(oExcelApp.ActiveWorkbook.Name);
oExcelApp = null;
An interesting thing happens when I run this code. On my home machine, it
works as expected. When I run this file on my work machine, it doesn't get
the reference to the Excel Application. oExcelApp is set to null and I get a
NullReferenceException on the MessageBox.Show line. I downloaded and
installed the PIA's at
http://www.microsoft.com/downloads/...3a-ac14-4125-8ba0-d36d67e0f4ad&displaylang=en
Both machines have Office 2003 installed(home also has Trial of Office 2007
installed)
The work machine also can not connect to Access.Application or
Outlook.Application either. It can, however, connect to Word.Application.
Another interesting note is that creating a new Excel Application works so
and I can manipulate an Excel Spreadsheet as expected, so the PIA's aren't
totally faulty.
I need an answer other than reinstalling Office since it is incredibly
impractical to have all users of the applications I develop to have to
reinstall Office if they encounter the same problem.
..Net Windows Application. I'm trying to connecti to an existing copy of Excel
I followed the instructions in http://support.microsoft.com/kb/316126
Excel.Application oExcelApp;
this.Activate();
oExcelApp =
(Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
MessageBox.Show(oExcelApp.ActiveWorkbook.Name);
oExcelApp = null;
An interesting thing happens when I run this code. On my home machine, it
works as expected. When I run this file on my work machine, it doesn't get
the reference to the Excel Application. oExcelApp is set to null and I get a
NullReferenceException on the MessageBox.Show line. I downloaded and
installed the PIA's at
http://www.microsoft.com/downloads/...3a-ac14-4125-8ba0-d36d67e0f4ad&displaylang=en
Both machines have Office 2003 installed(home also has Trial of Office 2007
installed)
The work machine also can not connect to Access.Application or
Outlook.Application either. It can, however, connect to Word.Application.
Another interesting note is that creating a new Excel Application works so
and I can manipulate an Excel Spreadsheet as expected, so the PIA's aren't
totally faulty.
I need an answer other than reinstalling Office since it is incredibly
impractical to have all users of the applications I develop to have to
reinstall Office if they encounter the same problem.