當前位置: 首頁>>代碼示例>>C#>>正文


C# Word.Document類代碼示例

本文整理匯總了C#中Microsoft.Office.Interop.Word.Document的典型用法代碼示例。如果您正苦於以下問題:C# Document類的具體用法?C# Document怎麽用?C# Document使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Document類屬於Microsoft.Office.Interop.Word命名空間,在下文中一共展示了Document類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: UrlListForm

        public UrlListForm(Word.Document doc)
        {
            InitializeComponent();

            if (doc == null)
                return;
            wordDoc = doc;

            hyperlink_urls = WordUrlManager.GetListOfHyperlinkUrls(doc);
            hyperlink_requests = new HttpWebRequest[hyperlink_urls.Length];
            autofind_urls = WordUrlManager.GetListOfAllUrls(doc);
            autofind_requests = new HttpWebRequest[autofind_urls.Length];
            active_urls = hyperlink_urls;
            active_requests = hyperlink_requests;

            InitializeUrlViewList();

            progressBar.Visible = true;
            if (active_urls.Length == 0)
                progressBar.Visible = false;
            progressBar.Minimum = 0;
            progressBar.Maximum = active_urls.Length;
            progressBar.Step = 1;
            progressBar.Value = 0;

            button_RecheckEveryURL.Enabled = false;
            radioButton_autofindUrls.Enabled = false;
            radioButton_wordHyperlinks.Enabled = false;
            listView.BeginUpdate();

            urlTesterThread = null;
            RestartTestingThread = null;
            urlTesterThread_shouldStop = false;
        }
開發者ID:ggmod,項目名稱:WordSyntaxHighlighter,代碼行數:34,代碼來源:UrlListForm.cs

示例2: Convert

        public override void Convert(String inputFile, String outputFile)
        {
            Object nothing = System.Reflection.Missing.Value;
            try
            {
                if (!File.Exists(inputFile))
                {
                    throw new ConvertException("File not Exists");
                }

                if (IsPasswordProtected(inputFile))
                {
                    throw new ConvertException("Password Exist");
                }

                app = new Word.Application();
                docs = app.Documents;
                doc = docs.Open(inputFile, false, true, false, nothing, nothing, true, nothing, nothing, nothing, nothing, false, false, nothing, true, nothing);
                doc.ExportAsFixedFormat(outputFile, Word.WdExportFormat.wdExportFormatPDF, false, Word.WdExportOptimizeFor.wdExportOptimizeForOnScreen, Microsoft.Office.Interop.Word.WdExportRange.wdExportAllDocument, 1, 1, Word.WdExportItem.wdExportDocumentContent, false, false, Word.WdExportCreateBookmarks.wdExportCreateNoBookmarks, false, false, false, nothing);
            }
            catch (Exception e)
            {
                release();
                throw new ConvertException(e.Message);
            }
            release();
        }
開發者ID:teambition,項目名稱:OfficeConverter,代碼行數:27,代碼來源:WordConverter.cs

示例3: getAttrValueInTag

 public String getAttrValueInTag(String tag, String attr, String subject)
 {
     if (log.IsInfoEnabled) log.Info("Begin");
     if (log.IsDebugEnabled) log.Debug("getAttrValueInTag(tag: " + tag + ", attr: " + attr + ")");
     /* Declaración de variables */
     String subjectString = null;
     String result = null;
     String pattern = null;
     Regex regexObj = null;
     Match matchResults = null;
     RegexOptions options = RegexOptions.IgnoreCase;
     /* Inicializamos variables */
     ActiveDocument = Globals.ThisAddIn.Application.ActiveDocument;
     pattern = @"\[" + tag + ".*?" + attr + @"=("".*?""|'.*?'|[^\ \]]*).*?\]";
     pattern = "\\[" + tag + ".*?" + attr + "=(\\\".*?\\\"|\\'.*?\\'|[^\\ \\]]*).*?\\]";
     subjectString = ActiveDocument.Content.Text;
     if (subject != null)
         subjectString = subject;
     /* Verificamos que haya coincidencia */
     regexObj = new Regex(pattern, options);
     matchResults = regexObj.Match(subjectString);
     if (matchResults.Success)
     {
         result = matchResults.Groups[1].Value;
         if (result.EndsWith("\"") || result.EndsWith("'"))
         {
             result = result.Substring(1, result.Length - 2);
         }
     }
     if (log.IsInfoEnabled) log.Info("End");
     return result;
 }
開發者ID:swarzesherz,項目名稱:RegexMarkup,代碼行數:32,代碼來源:Utils.cs

示例4: TechDoc2

        public TechDoc2(string TemplateFilename, bool Visible)
        {
            CurrentTechSection = 0;
            CurrentTechLine = 0;
            ItemSectionFormat = "{0}. ";
            ItemLineFormat = "{0}.{1}. ";

            WORDApp = new Word.ApplicationClass();
            WORDApp.Visible = true;

            object useDefaultValue = Type.Missing;
            object visible = Visible;
            object template = TemplateFilename;

            doc = WORDApp.Documents.Add(ref template, ref useDefaultValue, ref useDefaultValue, ref visible);

            //настройка стилей
            Word.Style SectionStyle = doc.Styles[Word.WdBuiltinStyle.wdStyleHeading1];
            SectionStyle.Font.Color = Word.WdColor.wdColorBlack;
            SectionStyle.Font.Name = "Calibri";
            SectionStyle.Font.Size = 16;

            Word.Style NormalStyle = doc.Styles[Word.WdBuiltinStyle.wdStyleNormal];
            NormalStyle.Font.Color = Word.WdColor.wdColorBlack;
            NormalStyle.Font.Name = "Calibri";
            NormalStyle.Font.Size = 12;
            //список таблиц документа
            TablesList = new Dictionary<string, Word.Table>();
            //список литературы
            BiblioList = new List<BiblioSource>();
        }
開發者ID:VLunev,項目名稱:RachetRR4,代碼行數:31,代碼來源:TechDoc2_WithOfficeInterop.cs

示例5: A

        public A()
        {
            oracon = new OracleConnection("server = 127.0.0.1/orcx; user id = qzdata; password = xie51");
            oracon2 = new OracleConnection("server = 10.5.67.11/pdbqz; user id = qzdata; password = qz9401tw");
            wordapp = new word.Application();
            worddoc = new word.Document();
            worddoc = wordapp.Documents.Add();

            worddoc.SpellingChecked = false;
            worddoc.ShowSpellingErrors = false;

     //       wordapp.Visible = true;
            ta.wordapp = wordapp;
            ta.worddoc = worddoc;
            if (IS_YEAR)
            {
                datestr = dsf.GetDateStr(the_year_begin_int, the_month_begin_int, the_year_end_int, the_month_end_int);
            }
            else
            {
                datestr = dsf.GetDateStr(the_date);
            }
            
       //     datestr_abid = "(" + datestr + "and a.ab_id >=1 and a.ab_id <= 7)";
            datestr_abid = "(" + datestr + "and" + abidstr + ")";
            oracon2.Open();
            orahlper = new OraHelper(oracon2);
            orahlper.feedback = true;

            the_month_begin = new DateTime(the_date.Year, the_date.Month, 1, 0, 0, 0);
            the_month_end = the_month_begin.AddMonths(1).AddSeconds(-1);

        }
開發者ID:xiexi1990,項目名稱:ReportGen,代碼行數:33,代碼來源:Program.cs

示例6: TEditSidebar

        public TEditSidebar(Word.Document WordDoc)
        {
            InitializeComponent();
            AxiomIRISRibbon.Utility.setTheme(this);

            this.tabDebug.Visibility = System.Windows.Visibility.Hidden;
            if (Globals.ThisAddIn.getDebug())
            {
                this.tabDebug.Visibility = System.Windows.Visibility.Visible;
            }

            this.D = Globals.ThisAddIn.getData();
            this.Doc = WordDoc;

            // Initiatlise the tables to hold the XML
            this.DTClauseXML = new DataTable();
            this.DTClauseXML.TableName = "ClauseXML";
            this.DTClauseXML.Columns.Add(new DataColumn("Id", typeof(String)));
            this.DTClauseXML.Columns.Add(new DataColumn("XML", typeof(String)));

            this.CurrentConceptId = "";
            this.CurrentClauseId = "";
            this.CurrentElementId = "";

            this.RefreshConceptList();
            this.GetDropDowns();

            this.ClauseLock = true;
            this.ForceRereshClauseXML = false;
        }
開發者ID:santoshsaha,項目名稱:AxiomCS-Ribbon,代碼行數:30,代碼來源:TEditSidebar.xaml.cs

示例7: WordDocument

        public WordDocument(String templateName, bool visible)
        {
            List<int> startedWords = new List<int>();

            foreach (Process p in System.Diagnostics.Process.GetProcessesByName("winword"))
            {
                startedWords.Add(p.Id);
            }

            Object missingValue = Missing.Value;
            Object template = templateName;
            if (wordapp == null)
                wordapp = new Word.Application();

            foreach (Process p in System.Diagnostics.Process.GetProcessesByName("winword"))
            {
                if (!startedWords.Contains(p.Id))
                {
                    IDs.Add(p.Id);
                }
            }
            wordapp.Visible = visible;
            doc = wordapp.Documents.Add(ref template,
            ref missingValue, ref missingValue, ref missingValue);
            doc.ActiveWindow.Selection.MoveEnd(Word.WdUnits.wdStory);

            tempFileName = Path.Combine(Path.GetDirectoryName(templateName), tempFileName);
        }
開發者ID:Tinkris,項目名稱:TeemTest,代碼行數:28,代碼來源:WordDocument.cs

示例8: setup

 public void setup()
 {
     wordApp = WordApplicationHelper.GetApplication();
     if (wordApp.Documents.Exists(IOHelpers.FirmAddressTestData))
         wordApp.Documents.First(IOHelpers.FirmAddressTestData).Close(Wd.WdSaveOptions.wdDoNotSaveChanges);
     doc = wordApp.Documents.Open(IOHelpers.FirmAddressTestData.FullName);
 }
開發者ID:beachandbytes,項目名稱:GorillaDocs,代碼行數:7,代碼來源:FirmAddressTests.cs

示例9: AddToc

        public void AddToc()
        {
            wordApp = new Application();
            object file = filePath;

            try
            {

                wordDocument = wordApp.Documents.Open(ref file, ref paramMissing, ref paramMissing,
                                    ref paramMissing, ref paramMissing, ref paramMissing,
                                    ref paramMissing, ref paramMissing, ref paramMissing,
                                    ref paramMissing, ref paramMissing, ref paramMissing,
                                    ref paramMissing, ref paramMissing, ref paramMissing,
                                    ref paramMissing
                );

                Range tocRange = wordDocument.Range(0, 0);
                TableOfContents toc = wordDocument.TablesOfContents.Add(tocRange, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing);
                toc.Update();

                int end = toc.Range.End;
                Range tocEnd = wordDocument.Range(end, end);

                tocEnd.InsertParagraphBefore();
                tocEnd.InsertBreak(WdBreakType.wdPageBreak);

            }
            catch (COMException ex)
            {
                throw new InvalidOperationException("Invalid Document", ex);
            }
            finally {
                Dispose();
            }
        }
開發者ID:amilasurendra,項目名稱:pdf-generator,代碼行數:35,代碼來源:PostProcessor.cs

示例10: WordGenerator

 /// <summary>
 /// Generates a word instance
 /// </summary>
 /// <param name="settings"></param>
 private WordGenerator(NamedLookup settings, bool silent) : base(settings, silent)
 {
     app = new Word.Application();
     app.Visible = !this.silent;
     document = app.Documents.Add(Type.Missing, Type.Missing,
     Word.WdNewDocumentType.wdNewBlankDocument, !this.silent);
     document.UserControl = !this.silent;
 }
開發者ID:acas,項目名稱:tfs-release-notes,代碼行數:12,代碼來源:WordGenerator.cs

示例11: AnnotationDisplay

 public AnnotationDisplay(Word.Document doc)
 {
     this.document = doc;
     displayedAnnotations = new List<Microsoft.Office.Interop.Word.Comment>();
     document.TextLineEnding = Microsoft.Office.Interop.Word.WdLineEndingType.wdLFOnly;
     document.Content.TextRetrievalMode.IncludeFieldCodes = true;
     document.Content.TextRetrievalMode.IncludeHiddenText = true;
     deletedCharsMap = document.Content.MapDeletedCharsOffsets();
     clearContent = document.Content.GetCleanedText();
 }
開發者ID:xwiki-contrib,項目名稱:xwiki-office,代碼行數:10,代碼來源:AnnotationDisplay.cs

示例12: ComposeDocument

 private void ComposeDocument(RepositoryInfo repositoryInfo, IList<Issue> issues, Document document)
 {
     foreach (Range tmpRange in document.StoryRanges)
     {
         Replace(repositoryInfo.ProjectName, ProjectNameContainer, tmpRange);
         Replace(repositoryInfo.Hash, VersionContainer, tmpRange);
         Replace(repositoryInfo.Date, PublicationDateContainer, tmpRange);
         Replace(issues.ToText(), SolvedTicketsContainer, tmpRange);
     }
 }
開發者ID:elpikel,項目名稱:Publisher,代碼行數:10,代碼來源:DocumentBuilder.cs

示例13: ConfirmForm

 public ConfirmForm(ThisAddIn myThisAddIn, Word.Application WordApp, object FileName)
 {
     InitializeComponent();
     this.myThisAddIn = myThisAddIn;
     this.WordApp = WordApp;
     this.FileName = FileName;
     OldDocument = WordApp.ActiveDocument;
     isCancelFlag = false;
     ClosePrintPreviewThread = new Thread(new ThreadStart(ClosePrintPreviewListener));
     ClosePrintPreviewThread.Start();
 }
開發者ID:chendaxixi,項目名稱:WordAddIn,代碼行數:11,代碼來源:ConfirmForm.cs

示例14: documentListBox_SelectedIndexChanged

 private void documentListBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     // When a document is selected in the list, change the current selected document
     if (documentListBox.SelectedIndex >= 0)
     {
         if (wordObj != null)
         {
             docObj = wordObj.Documents[documentListBox.SelectedIndex + 1];
         }
     }
 }
開發者ID:rfoligno,項目名稱:word_countdown,代碼行數:11,代碼來源:MainForm.cs

示例15: translateButton_Click

 private void translateButton_Click(object sender, RibbonControlEventArgs e)
 {
     document = (Word.Document)inspector.WordEditor;
     if (document != null)
     {
         string selected = document.Application.Selection.Text;
         if (selected.Length > 0)
         {
             document.Application.Selection.Text = translate(selected);
         }
     }
 }
開發者ID:dunckr,項目名稱:outlook-translate,代碼行數:12,代碼來源:MailRibbon.cs


注:本文中的Microsoft.Office.Interop.Word.Document類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。