protected static string OpenWord(string Path)
        {
            Word._Application application = null;;
            Word._Document    document    = null;;

            Object _Path = Path;

            try
            {
                application = new Word.Application();
                if (!string.IsNullOrEmpty(_Path.ToString()))
                {
                    document = application.Documents.Open(ref _Path, Type.Missing, (object)false);
                }
                application.Visible = true;
            }
            catch (Exception error)
            {
                try
                {
                    document.Close();
                }
                catch { }
                try
                {
                    application.Quit();
                }
                catch { }
                document    = null;
                application = null;
                return(error.Message + "innerExeption: " + error.InnerException.Message);
            }
            return("Succed");
        }
Example #2
0
        public Open(object app, Connect connect)
        {
            m_DelegateIncrementProgressBar = new DelegateIncrementProgressBar(this.IncrementProgressBar);
            m_DelegateDrawFileList = new DelegateDrawFileList(this.DrawFileList);
            m_DelegateRemoveProgressBar = new DelegateRemoveProgressBar(this.RemoveProgressBar);
            m_DelegateCreateProgressBar = new DelegateCreateProgressBar(this.CreateProgressBar);
            m_DelegateInhibControl_Off = new DelegateInhibControl_Off(this.InhibControls_Off);
            m_DelegateInhibControl_On = new DelegateInhibControl_On(this.InhibControls_On);

            this.app = (Word._Application)app;
            this.connect = connect;

            InitializeComponent();
        }
Example #3
0
        public Publish(object app)
        {
            d_SetDownloadState = new SetDownloadState(this.SetDownloadStateMethod);
            d_CloseWindows = new CloseWindows(this.CloseWindowsMethod);
            d_ErrorWindow = new ErrorWindow(this.LaunchErrorWindow);
            this.app = (Word._Application)app;

            if (IsPengYouDocument() == true && GetPublishPath() == true)
            {
                PublishDoc();
            }
            else
            {
                error_reason = "This document is not a valid PengYou Document";
                LaunchErrorWindow();
            }

            InitializeComponent();
        }
Example #4
0
        public static Word._Document WordOpenForWrite(Word._Application wordApp, object objDocName)
        {
            return(wordApp.Documents.Open(
                       ref objDocName,   //FileName
                       ref ObjMissing,   //ConfirmVersions
                       ref ObjFalse,     //ReadOnly
                       ref ObjMissing,   //AddToRecentFiles
                       ref ObjMissing,   //PasswordDocument
                       ref ObjMissing,   //PasswordTemplate
                       ref ObjMissing,   //Revert
                       ref ObjMissing,   //WritePasswordDocument
                       ref ObjMissing,   //WritePasswordTemplate
                       ref ObjMissing,   //Format
                       ref ObjMissing,   //Enconding
                       ref ObjMissing    //Visible
#if OFFICE2003
                       , ref ObjMissing, //OpenAndRepair
                       ref ObjMissing,   //DocumentDirection
                       ref ObjMissing,   //NoEncodingDialog
                       ref ObjMissing    //XMLTransform*/
#endif
                       ));
        }
Example #5
0
        public void OnStartupComplete(ref System.Array custom)
        {
            CommandBars oCommandBars;

            CommandBar oStandardBar;

            object omissing = System.Reflection.Missing.Value;

            app =  (Word._Application)applicationObject;
            app.CustomizationContext = app.NormalTemplate;

            try
            {
                oCommandBars = (CommandBars)applicationObject.GetType().InvokeMember("CommandBars", BindingFlags.GetProperty, null, applicationObject, null);
            }
            catch (Exception)
            {
                return;
            }

            // Set up a custom button on the "Standard" commandbar.
            try
            {
                oStandardBar = oCommandBars["Menu Bar"];

            }
            catch (Exception)
            {
                return;
            }

            CommandBarControls controls = oStandardBar.Controls;

            // remove old menus...
            foreach (CommandBarControl control in controls)
            {
                String caption = control.Caption;

                if ( caption.EndsWith("Remote Documents") || caption.EndsWith("Remote documents"))
                {
                    control.Delete(null);
                }
            }

                eXoMenu = (CommandBarPopup)oStandardBar.Controls.Add(MsoControlType.msoControlPopup, omissing, omissing, omissing, true);
                eXoMenu.Caption = "Remote Documents";
                eXoMenu.Tag = eXoMenu.Caption;

                Open = (CommandBarButton)eXoMenu.Controls.Add(1, omissing, omissing, omissing, omissing);
                Open.Caption = "Open...";
                Open.Tag = Open.Caption;

                Save = (CommandBarButton)eXoMenu.Controls.Add(1, omissing, omissing, omissing, omissing);
                Save.Caption = "Save";
                Save.Tag = Save.Caption;

                SaveAs = (CommandBarButton)eXoMenu.Controls.Add(1, omissing, omissing, omissing, omissing);
                SaveAs.Caption = "Save As...";
                SaveAs.Tag = SaveAs.Caption;

                Search = (CommandBarButton)eXoMenu.Controls.Add(1, omissing, omissing, omissing, omissing);
                Search.Caption = "Search...";
                Search.Tag = Search.Caption;

                Settings = (CommandBarButton)eXoMenu.Controls.Add(1, omissing, omissing, omissing, omissing);
                Settings.Caption = "Settings...";
                Settings.Tag = Settings.Caption;

                About = (CommandBarButton)eXoMenu.Controls.Add(1, omissing, omissing, omissing, omissing);
                About.Caption = "About...";
                About.Tag = About.Caption;

            Open.Visible = true;
            Open.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.Open_Click);

            Save.Visible = true;
            //Save.Enabled = false;
            Save.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.Save_Click);

            SaveAs.Visible = true;
            //SaveAs.Enabled = false;
            SaveAs.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.SaveAs_Click);

            //CompareWithBase.Visible = true;
            //CompareWithBase.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.compareWithBase_Click);

            Search.Visible = true;
            Search.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.Search_Click);

            Settings.Visible = true;
            Settings.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.Settings_Click);

            About.Visible = true;
            About.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.About_Click);

            object oName = applicationObject.GetType().InvokeMember("Name", BindingFlags.GetProperty, null, applicationObject, null);
            oStandardBar = null;
            oCommandBars = null;

            clearRepository();
        }
Example #6
0
 public static void WordQuit(Word._Application wordApp)
 {
     wordApp.Quit(ref ObjMissing, ref ObjMissing, ref ObjMissing);
 }
Example #7
0
 public static Word._Document AddDocument(Word._Application wordApp)
 {
     return(wordApp.Documents.AddOld(ref ObjMissing, ref ObjMissing));
 }
Example #8
0
        public void OnStartupComplete(ref System.Array custom)
        {
            CommandBars oCommandBars;
            CommandBar oStandardBar;
            object omissing = System.Reflection.Missing.Value;

            app = (Word._Application)applicationObject;

            try
            {
                oCommandBars = (CommandBars)applicationObject.GetType().InvokeMember("CommandBars", BindingFlags.GetProperty, null, applicationObject, null);
            }
            catch (Exception)
            {
                // Outlook has the CommandBars collection on the Explorer object.
                object oActiveExplorer;
                oActiveExplorer = applicationObject.GetType().InvokeMember("ActiveExplorer", BindingFlags.GetProperty, null, applicationObject, null);
                oCommandBars = (CommandBars)oActiveExplorer.GetType().InvokeMember("CommandBars", BindingFlags.GetProperty, null, oActiveExplorer, null);
            }

            // Set up a custom button on the "Standard" commandbar.
            try
            {
                oStandardBar = oCommandBars["Menu Bar"];
            }
            catch (Exception)
            {
                // Access names its main toolbar Database.
                oStandardBar = oCommandBars["Database"];
            }

            // In case the button was not deleted, use the exiting one.
            try
            {
                PengYouMenu = (CommandBarPopup)oStandardBar.Controls["Documents distants"];
                Open = (CommandBarButton)PengYouMenu.Controls["Ouvrir..."];
                Publish = (CommandBarButton)PengYouMenu.Controls["Publier"];
                PublishAs = (CommandBarButton)PengYouMenu.Controls["Publier sous..."];
               // Publish.BeginGroup = true;

            }
            catch (Exception)
            {
                PengYouMenu = (CommandBarPopup)oStandardBar.Controls.Add(MsoControlType.msoControlPopup, omissing, omissing, omissing, true);
                PengYouMenu.Caption = "Documents distants";
                PengYouMenu.Tag = PengYouMenu.Caption;

                Open = (CommandBarButton)PengYouMenu.Controls.Add(1, omissing, omissing, omissing, omissing);
                Open.Caption = "Ouvrir...";
                Open.Tag = Open.Caption;

                Publish = (CommandBarButton)PengYouMenu.Controls.Add(1, omissing, omissing, omissing, omissing);
                Publish.Caption = "Publier";
                Publish.Tag = Publish.Caption;

                PublishAs = (CommandBarButton)PengYouMenu.Controls.Add(1, omissing, omissing, omissing, omissing);
                PublishAs.Caption = "Publier sous...";
                PublishAs.Tag = PublishAs.Caption;
                //Publish.BeginGroup = true;
            }

            Publish.Visible = true;
            Publish.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.Publish_Click);

            PublishAs.Visible = true;
            PublishAs.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.PublishAs_Click);

            Open.Visible = true;
            Open.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.Open_Click);

            object oName = applicationObject.GetType().InvokeMember("Name", BindingFlags.GetProperty, null, applicationObject, null);
            oStandardBar = null;
            oCommandBars = null;
        }