Пример #1
0
        protected override OfficeDocument Open(System.IO.FileInfo file)
        {
            OfficeDocument officeDocument = null;
            object         filedocxtoOpen = file.FullName;
            object         missing        = Type.Missing;

            Word.Document doc = application.Documents.Open(ref filedocxtoOpen, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
            officeDocument = new Word2010OfficeDocument(doc);
            return(officeDocument);
        }
Пример #2
0
        protected override OfficeDocument Open(System.IO.FileInfo file, String contentid, String rep)
        {
            object         missing        = Type.Missing;
            object         format         = Word.WdSaveFormat.wdFormatDocument;
            OfficeDocument officeDocument = null;
            object         filedocxtoOpen = file.FullName;

            if (file.Exists)
            {
                try
                {
                    Word.Document doc = application.Documents.Open(ref filedocxtoOpen, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
                    officeDocument = new Word2010OfficeDocument(doc);
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.StackTrace);
                    String   path  = file.FullName.Replace(".doc", ".html");
                    FileInfo fHTML = new FileInfo(path);
                    if (fHTML.Exists)
                    {
                        filedocxtoOpen = path;
                        Word.Document doc = application.Documents.Open(ref filedocxtoOpen, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
                        filedocxtoOpen = file.FullName;
                        doc.SaveAs(ref filedocxtoOpen, ref format, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
                        doc.ActiveWindow.View.Type = Word.WdViewType.wdPrintView;
                        officeDocument             = new Word2010OfficeDocument(doc);
                    }
                }
            }
            else
            {
                String   path  = file.FullName.Replace(".doc", ".html");
                FileInfo fHTML = new FileInfo(path);
                if (fHTML.Exists)
                {
                    filedocxtoOpen = path;
                    Word.Document doc = application.Documents.Open(ref filedocxtoOpen, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
                    filedocxtoOpen = file.FullName;
                    doc.SaveAs(ref filedocxtoOpen, ref format, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
                    doc.ActiveWindow.View.Type = Word.WdViewType.wdPrintView;
                    officeDocument             = new Word2010OfficeDocument(doc);
                }
            }
            if (officeDocument != null)
            {
                officeDocument.SaveContentProperties(contentid, rep);
                if (MenuListener != null)
                {
                    MenuListener.DocumentPublished();
                }
            }
            return(officeDocument);
        }
Пример #3
0
 private void ActivateDocument(Microsoft.Office.Interop.Word.Document document)
 {
     if (document != null)
     {
         OfficeDocument officeDocument = new Word2010OfficeDocument(document);
         if (officeDocument.IsPublished)
         {
             if (MenuListener != null)
             {
                 OfficeApplication.MenuListener.DocumentPublished();
             }
         }
         else
         {
             if (MenuListener != null)
             {
                 OfficeApplication.MenuListener.NoDocumentPublished();
             }
         }
     }
 }