예제 #1
0
        private static IDisposableSequence GetActiveExcelApplicationProxiesFromDesktop()
        {
            try
            {
                WindowEnumerator enumerator = new WindowEnumerator("XLMAIN");
                IntPtr[]         handles    = enumerator.EnumerateWindows(2000);
                if (null == handles || handles.Length == 0)
                {
                    return(new DisposableObjectList(null));
                }

                return(ExcelApplicationWindow.GetApplicationProxiesFromHandle(handles));
            }
            catch (Exception exception)
            {
                DebugConsole.Default.WriteException(exception);
                throw;
            }
        }
예제 #2
0
        private static object GetActiveExcelApplicationProxyFromDesktop()
        {
            try
            {
                WindowEnumerator enumerator = new WindowEnumerator("XLMAIN");
                IntPtr[]         handles    = enumerator.EnumerateWindows(2000);
                if (null == handles || handles.Length == 0)
                {
                    return(null);
                }

                object proxy = ExcelApplicationWindow.GetApplicationProxyFromHandle(handles[0]);
                return(proxy);
            }
            catch (Exception exception)
            {
                DebugConsole.Default.WriteException(exception);
                throw;
            }
        }