Click here to Skip to main content
15,903,806 members
Home / Discussions / COM
   

COM

 
GeneralRe: IRunningObjectTable.GetObject() not returning the object Pin
lee2324-May-09 13:59
lee2324-May-09 13:59 
GeneralRe: IRunningObjectTable.GetObject() not returning the object Pin
Stuart Dootson25-May-09 1:17
professionalStuart Dootson25-May-09 1:17 
Questionmschart Pin
aysl20-May-09 2:20
aysl20-May-09 2:20 
AnswerRe: mschart Pin
Baltoro20-May-09 14:13
Baltoro20-May-09 14:13 
AnswerRe: mschart Pin
kilt20-May-09 21:01
kilt20-May-09 21:01 
QuestionROTFLAGS_ALLOWANYCLIENT & AppID Pin
lee2319-May-09 21:16
lee2319-May-09 21:16 
AnswerRe: ROTFLAGS_ALLOWANYCLIENT & AppID Pin
Stuart Dootson19-May-09 22:29
professionalStuart Dootson19-May-09 22:29 
GeneralRe: ROTFLAGS_ALLOWANYCLIENT & AppID Pin
lee2320-May-09 0:05
lee2320-May-09 0:05 
GeneralRe: ROTFLAGS_ALLOWANYCLIENT & AppID Pin
Stuart Dootson20-May-09 1:17
professionalStuart Dootson20-May-09 1:17 
GeneralRe: ROTFLAGS_ALLOWANYCLIENT & AppID Pin
lee2320-May-09 1:46
lee2320-May-09 1:46 
GeneralRe: ROTFLAGS_ALLOWANYCLIENT & AppID Pin
Stuart Dootson20-May-09 2:06
professionalStuart Dootson20-May-09 2:06 
GeneralRe: ROTFLAGS_ALLOWANYCLIENT & AppID [modified] Pin
lee2320-May-09 21:30
lee2320-May-09 21:30 
GeneralRe: ROTFLAGS_ALLOWANYCLIENT & AppID Pin
Stuart Dootson20-May-09 23:50
professionalStuart Dootson20-May-09 23:50 
QuestionProblem with build order of .idl files in visual studio 2005 [modified] Pin
Atulp118-May-09 19:41
Atulp118-May-09 19:41 
AnswerRe: Problem with build order of .idl files in visual studio 2005 Pin
Stuart Dootson18-May-09 22:21
professionalStuart Dootson18-May-09 22:21 
Questionintegrating 'Microsoft office project' Dcom with asp.net Pin
mahesvs16-May-09 9:26
mahesvs16-May-09 9:26 
Questionincreasing security of activex Pin
mazizi16-May-09 0:21
mazizi16-May-09 0:21 
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

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.