Click here to Skip to main content
15,887,318 members
Home / Discussions / COM
   

COM

 
AnswerDifficult to Understand your Question Pin
Baltoro16-May-09 9:08
Baltoro16-May-09 9:08 
GeneralRe: Difficult to Understand your Question Pin
mazizi17-May-09 18:45
mazizi17-May-09 18:45 
Generalsorry Pin
Baltoro20-May-09 14:22
Baltoro20-May-09 14:22 
Questionproblem in query interface Pin
chandrakar ashish14-May-09 21:27
chandrakar ashish14-May-09 21:27 
AnswerRe: problem in query interface Pin
Stuart Dootson15-May-09 0:12
professionalStuart Dootson15-May-09 0:12 
AnswerRe: problem in query interface Pin
«_Superman_»15-May-09 5:19
professional«_Superman_»15-May-09 5:19 
AnswerRe: problem in query interface Pin
Jürgen Jung15-May-09 5:39
Jürgen Jung15-May-09 5:39 
QuestionExcel 2007 automation on top of a Windows Server 2008 x64 [modified] Pin
Chris Richner14-May-09 10:24
Chris Richner14-May-09 10:24 
I’m well aware of the Microsoft support base article stating that it’s not supported to automate office products UI less. It seems that Windows Server 2008 and Excel 2007 enforce the given statement.

I’m running the following code in a NT Service (Local System account) OnStart method. All it does is Excel automation the way it’s working when you run the same code in a Console Application.

The provided code has two parts. The first part launches Excel, creates a new work book and saves it to the given filename. The second part launches a new instance of Excel and opens the given file. The open operation ends in this exception:

Service cannot be started. System.Runtime.InteropServices.COMException (0x800A03EC): Microsoft Office Excel cannot access the file 'c:\temp\test.xls'. There are several possible reasons:

• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open workbook.

Why was the automated excel able to launch and write files to disk but fails when it’s asked “just “ to open an existing file?

System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
            // launch excel and create/save a new work book
            Microsoft.Office.Interop.Excel.ApplicationClass excel = new Microsoft.Office.Interop.Excel.ApplicationClass();
excel.UserLibraryPath, excel.Interactive));
            //            
            string filename = "c:\\temp\\test.xls";
            if(System.IO.File.Exists(filename)) System.IO.File.Delete(filename);
            //
            excel.Workbooks.Add(System.Reflection.Missing.Value);
            excel.Save(filename);
            excel.Quit();
            excel = null;
            // lauch new instance of excel and open saved file
            excel = new Microsoft.Office.Interop.Excel.ApplicationClass();
            try
            {
                Microsoft.Office.Interop.Excel.Workbook book = excel.Workbooks.Open(filename,
                    System.Reflection.Missing.Value,
                    System.Reflection.Missing.Value,
                    System.Reflection.Missing.Value,
                    System.Reflection.Missing.Value,
                    System.Reflection.Missing.Value,
                    true,
                    System.Reflection.Missing.Value,
                    System.Reflection.Missing.Value,
                    false,
                    false,
                    System.Reflection.Missing.Value,
                    false,
                    System.Reflection.Missing.Value,
                    System.Reflection.Missing.Value);
                book.Close(false, System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                book = null;
            }
            finally
            {
                excel.Quit();
                excel = null;
            }
            //
            GC.Collect();



modified on Thursday, May 14, 2009 4:32 PM

Questionout-of-proc c# COM server: AccessViolationException in .net client Pin
thorben50014-May-09 9:27
thorben50014-May-09 9:27 
QuestionE_UNEXPECTED when calling SafeArrayAccessData Pin
Cajunman082114-May-09 3:30
Cajunman082114-May-09 3:30 
AnswerRe: E_UNEXPECTED when calling SafeArrayAccessData Pin
Cajunman082114-May-09 4:12
Cajunman082114-May-09 4:12 
GeneralRe: E_UNEXPECTED when calling SafeArrayAccessData Pin
Cajunman082114-May-09 6:39
Cajunman082114-May-09 6:39 
GeneralRe: E_UNEXPECTED when calling SafeArrayAccessData Pin
Lim Bio Liong14-May-09 22:39
Lim Bio Liong14-May-09 22:39 
GeneralRe: E_UNEXPECTED when calling SafeArrayAccessData Pin
Vi217-May-09 23:45
Vi217-May-09 23:45 
GeneralRe: E_UNEXPECTED when calling SafeArrayAccessData Pin
Cajunman082118-May-09 1:51
Cajunman082118-May-09 1:51 
QuestionTurn Off Bluetooth using Com [modified] Pin
elluna14-May-09 2:47
elluna14-May-09 2:47 
AnswerRe: Turn Off Bluetooth using Com Pin
elluna17-May-09 19:22
elluna17-May-09 19:22 
QuestionHow to use activeX function that has a pointer parameter in JavaScript? [modified] Pin
lynn100712-May-09 16:01
lynn100712-May-09 16:01 
AnswerRe: How to use activeX function that has a pointer parameter in JavaScript? Pin
CPallini12-May-09 23:33
mveCPallini12-May-09 23:33 
GeneralRe: How to use activeX function that has a pointer parameter in JavaScript? Pin
lynn100713-May-09 2:09
lynn100713-May-09 2:09 
Questionmonikers Pin
monemshalash12-May-09 9:05
monemshalash12-May-09 9:05 
AnswerRe: monikers Pin
«_Superman_»12-May-09 19:40
professional«_Superman_»12-May-09 19:40 
GeneralRe: monikers Pin
monemshalash14-May-09 1:48
monemshalash14-May-09 1:48 
AnswerRe: monikers Pin
Baltoro14-May-09 5:44
Baltoro14-May-09 5:44 
Question.NET1.1 cannot create COM Object created with Net2.0 ?? Pin
Member 257016711-May-09 1:21
Member 257016711-May-09 1:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.