• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Interop.Word类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.Office.Interop.Word的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Office.Interop.Word类的具体用法?C# Microsoft.Office.Interop.Word怎么用?C# Microsoft.Office.Interop.Word使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Microsoft.Office.Interop.Word类属于命名空间,在下文中一共展示了Microsoft.Office.Interop.Word类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: HumanMacroDialog

        public HumanMacroDialog(Word.Range text, int jobNumber)
        {
            this.text = text;
            this.jobNumber = jobNumber;
            InitializeComponent();

            Binding binding = new Binding();
            binding.Source = text;
            binding.Path = new PropertyPath("Text");
            textToWorkWith.SetBinding(TextBox.TextProperty, binding);

            numItems.Content = numSections + " paragraph" + (numSections == 1 ? "" : "s") + " selected, each as a separate task";

            item1 = new ComboBoxItem();
            item1.Content = "Paragraph";
            item2 = new ComboBoxItem();
            item2.Content = "Sentence";

            separatorBox.Items.Add(item1);
            separatorBox.Items.Add(item2);
            separatorBox.SelectedValue = item1;

            returnAsComments = new ComboBoxItem();
            returnAsComments.Content = "Comments";
            returnAsInline = new ComboBoxItem();
            returnAsInline.Content = "In-Line Changes";
            returnTypeBox.Items.Add(returnAsComments);
            returnTypeBox.Items.Add(returnAsInline);
            returnTypeBox.SelectedValue = returnAsComments;
        }
开发者ID:tummykung,项目名称:soylent,代码行数:30,代码来源:HumanMacroDialog.xaml.cs


示例2: 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


示例3: FormFormatDate

        public FormFormatDate(Word.ContentControl currentCC)
        {
            InitializeComponent();

            this.currentCC = currentCC;

            if (currentCC.XMLMapping.IsMapped)
            {
                String dateValue = currentCC.XMLMapping.CustomXMLNode.Text;
                if (!DateTime.TryParse(dateValue, out thisDate1)) {
                    thisDate1 = DateTime.Now;
                    }
            }
            else
            {
                thisDate1 = DateTime.Now;
            }

            for (int i = 0; i < formatValues.Length; i++)
            {
                FormatChoice fc = new FormatChoice();
                fc.format = formatValues[i];
                fc.display = thisDate1.ToString(fc.format);
                this.listBoxFormat.Items.Add(fc);
            }

            if (currentCC.DateDisplayFormat != null)
            {
                this.textBoxFormat.Text = currentCC.DateDisplayFormat;
            }
        }
开发者ID:plutext,项目名称:OpenDoPE-NoXML-WordAddIn,代码行数:31,代码来源:FormFormatDate.cs


示例4: areOpenDoPEPartsPresent

        public static bool areOpenDoPEPartsPresent(Word.Document document)
        {
            // TODO consider removing this, or moving it,
            // refer instead Model.cs

            // Modified from OpenDoPE_Wed ThisAddIn
            Office.CustomXMLPart xpathsPart = null;
            Office.CustomXMLPart conditionsPart = null;

            foreach (Office.CustomXMLPart cp in document.CustomXMLParts)
            {
                if (cp.NamespaceURI.Equals(Namespaces.XPATHS))
                {
                    // check for duplicate parts; introduced 2013 12 08
                    if (xpathsPart != null)
                    {
                        MessageBox.Show("Duplicate parts detected. This template needs to be manually repaired.  Please contact your help desk.");
                    }

                    xpathsPart = cp;
                }
                else if (cp.NamespaceURI.Equals(Namespaces.CONDITIONS))
                {
                    conditionsPart = cp;
                }
            }

            return (xpathsPart != null && conditionsPart != null);
        }
开发者ID:plutext,项目名称:OpenDoPE-Model,代码行数:29,代码来源:CustomXmlUtilities.cs


示例5: collectWord

        public string collectWord(Word.Document doc)
        {
            doc.ActiveWindow.Selection.WholeStory();
            string str = doc.ActiveWindow.Selection.Text;

            return analyze(str);
        }
开发者ID:gosh-project,项目名称:gosh-officer,代码行数:7,代码来源:WordTest.cs


示例6: ProcessParagraphs

		protected bool ProcessParagraphs(OfficeDocumentProcessor aWordProcessor, Word.Paragraphs aParagraphs)
		{
			foreach (Word.Paragraph aParagraph in aParagraphs)
			{
				// get the Range object for this paragraph
				Word.Range aParagraphRange = aParagraph.Range;

				// if we're picking up where we left off and we're not there yet...
				int nCharIndex = 0;
				if (aWordProcessor.AreLeftOvers)
				{
					if (aWordProcessor.LeftOvers.Start > aParagraphRange.End)
						continue;   // skip to the next paragraph

					nCharIndex = aWordProcessor.LeftOvers.StartIndex;
					aWordProcessor.LeftOvers = null; // turn off "left overs"
				}

				WordRange aThisParagraph = new WordRange(aParagraphRange);
				if (!ProcessRangeAsWords(aWordProcessor, aThisParagraph, nCharIndex))
					return false;
			}

			return true;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:25,代码来源:WordDocumentProcessor.cs


示例7: getRepeatAncestor

        public Word.ContentControl getRepeatAncestor(Word.ContentControl cc)
        {
            Word.ContentControl repeatAncestor = null;

            if (root != null
                && !treeViewRepeat.SelectedNode.Equals(root)) // this varies with some repeat
            {
                // Which one is checked?
                string variesInRepeatId = (string)treeViewRepeat.SelectedNode.Tag;

                Word.ContentControl currentCC = cc.ParentContentControl;
                while (repeatAncestor == null && currentCC != null)
                {
                    if (currentCC.Tag.Contains("od:repeat"))
                    {
                        TagData td = new TagData(currentCC.Tag);
                        string variesXPathID = td.getRepeatID();

                        if (variesXPathID.Equals(variesInRepeatId))
                        {
                            return currentCC;
                        }
                    }
                    currentCC = currentCC.ParentContentControl;
                }
            }

            return null;
        }
开发者ID:plutext,项目名称:OpenDoPE-NoXML-WordAddIn,代码行数:29,代码来源:ControlQuestionVaryWhichRepeat.cs


示例8: WordActiveDocument

        public WordActiveDocument(IOfficeApplication application, MsWord._Document document)
            : base(application, document.FullName)
        {
            _document = document;

            InitializeWsDocument(FullPath);
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:7,代码来源:WordActiveDocument.cs


示例9: WordUrlManager

 public WordUrlManager(Word.Application wordApp)
 {
     Word.Options options = wordApp.Application.Options;
     originalSettings_ReplaceHyperlinks = options.AutoFormatReplaceHyperlinks;
     originalSettings_AsYouTypeReplaceHyperlinks = options.AutoFormatAsYouTypeReplaceHyperlinks;
     wordAppOptionsChanged = false;
 }
开发者ID:ggmod,项目名称:WordSyntaxHighlighter,代码行数:7,代码来源:WordUrlManager.cs


示例10: OpenDocument

 //private static Word.Application wordapp = new Word.Application();
 public static Document OpenDocument(Word.Application wordapp, string fileName)
 {
     wordapp.Visible = true;
     //Setting for open
     string FileName = fileName;
     bool ConfirmConversions = false;
     bool ReadOnly = false;
     bool AddToRecentFiles = false;
     object PasswordDocument = missing;
     object PasswordTemplate = missing;
     bool Revert = false;
     object WritePasswordDocument = missing;
     object WritePasswordTemplate = missing;
     object Format = missing;
     object Encoding = missing;
     bool Visible = true;
     bool OpenAndRepair = true;
     object DocumentDirection = missing;
     bool NoEncodingDialog = false;
     object XMLTransform = missing;
     //
     return  wordapp.Documents.Open(FileName, ConfirmConversions, ReadOnly, AddToRecentFiles,
                                                 PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument,
                                                 WritePasswordTemplate, Format, Encoding, Visible, OpenAndRepair,
                                                 DocumentDirection = missing, NoEncodingDialog, XMLTransform);
 }
开发者ID:IamMan,项目名称:ModelingSignals,代码行数:27,代码来源:MSWordFunctionsProvider.cs


示例11: CreateContact

        private WorkContact CreateContact(Word.Row row, WorkGroup latestGroup)
        {
            try
            {
                //Trainers, Misc and Office have strange formats so don't do them
                if (latestGroup != WorkGroup.Trainer && latestGroup != WorkGroup.Misc && latestGroup != WorkGroup.Office)
                {
                    string nameAndInitials = GetNameAndInitials(row);
                    string[] nameFields = nameAndInitials.Split(' ');
                    string firstname = GetFirstName(nameFields);
                    string surname = GetSurname(nameFields);
                    string initials = GetInitials(nameFields);
                    string mobile = GetMobileNumber(row);
                    string home = GetHomeNumber(row);

                    //if there is at least one number then we can reasonably assume it's a contact
                    if (!string.IsNullOrWhiteSpace(mobile) || !string.IsNullOrWhiteSpace(home))
                    {
                        return WorkContact.FactoryCreate(firstname, surname, initials, mobile, home, latestGroup);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Had the following exception: " + e.Message);
                Console.WriteLine(e.StackTrace);
            }
            return null;
        }
开发者ID:stuartleyland,项目名称:MaintainWorkContacts,代码行数:29,代码来源:WordDocumentParser.cs


示例12: OpenNewApplication

 public static void OpenNewApplication(Word.Application WordApp, object FileName)
 {
     WordApp.Documents.Open(ref FileName,
        ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
        ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
        ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);  //新的程序打开原文档
 }
开发者ID:chendaxixi,项目名称:WordAddIn,代码行数:7,代码来源:Tools.cs


示例13: showHome

 public void showHome(Word.Application WordApp)
 {
     this.UseWordApp = WordApp;
     this.webBrowser1.ObjectForScripting = this;
     this.webBrowser1.Navigate(new Uri("http://localhost:8080/alfresco/template?templatePath=/Company%20Home/Data%20Dictionary/Presentation%20Templates/office/my_alfresco.ftl&contextPath=/Company%20Home/Data%20Dictionary/Presentation%20Templates/office/my_alfresco.ftl"));
     //this.webBrowser1.Navigate(new Uri("http://www.alfresco.com"));
 }
开发者ID:negabaro,项目名称:alfresco,代码行数:7,代码来源:UserControl1.cs


示例14: Find

        public static Wd.Range Find(this Wd.Range range, Wd.WdFieldType type, string value = null)
        {
            var ShowAll = range.Document.ActiveWindow.View.ShowAll;
            var ShowFieldCodes = range.Document.ActiveWindow.View.ShowFieldCodes;

            try
            {
                range.Document.ActiveWindow.View.ShowAll = true;
                range.Document.ActiveWindow.View.ShowFieldCodes = true;
                value = string.Format("^d {0}^w{1}", type.AsGoToString(), value);

                Wd.Range result = range.Duplicate;
                Wd.Find find = result.Find;
                find.ClearFormatting();
                find.Text = value;
                find.Forward = true;
                find.Wrap = Wd.WdFindWrap.wdFindStop;
                find.Forward = true;
                find.MatchCase = false;
                find.MatchWholeWord = false;
                find.MatchWildcards = false;
                find.MatchSoundsLike = false;
                find.MatchAllWordForms = false;
                find.Execute();

                return result;
            }
            finally
            {
                range.Document.ActiveWindow.View.ShowAll = ShowAll;
                range.Document.ActiveWindow.View.ShowFieldCodes = ShowFieldCodes;
            }
        }
开发者ID:beachandbytes,项目名称:GorillaDocs,代码行数:33,代码来源:SearchHelper.cs


示例15: 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


示例16: WriteDocumentAsXMLFile

 private void WriteDocumentAsXMLFile(Word.Range doc, string pathAndFile)
 {
     System.Xml.XmlWriter xw = null;
     try
     {
         System.Diagnostics.Stopwatch sw = new Stopwatch();
         sw.Start();
         System.IO.FileStream fs = System.IO.File.OpenWrite(pathAndFile);
         fs.SetLength(0);
         xw = System.Xml.XmlWriter.Create(fs
           , new System.Xml.XmlWriterSettings { Indent = true, CloseOutput = true });
         xw.WriteStartDocument();
         xw.WriteStartElement(EL_DOC);
         DomProcessor dp = new DomProcessor(doc, xw);
         dp.Process();
         xw.WriteEndElement();
         xw.WriteEndDocument();
         sw.Stop();
         MessageBox.Show("Elapsed time: " + sw.Elapsed.ToString());
     }
     finally
     {
         if (xw != null)
         {
             xw.Close();
         }
     }
 }
开发者ID:mikedamay,项目名称:maven_commentary,代码行数:28,代码来源:DocumentController.cs


示例17: Form

        public static void Form(string Ftext, string Rtext, Word.Document doc)
        {
            var range = doc.Content;

                range.Find.ClearFormatting();
                range.Find.Execute(FindText: Ftext, ReplaceWith: Rtext);
        }
开发者ID:ruhex,项目名称:ais,代码行数:7,代码来源:DocForm.cs


示例18: CreateNewWordDocument

        /// <summary>  
        /// 从模板创建新的Word文档,  
        /// </summary>  
        /// <param name="templateName">模板文件名</param>  
        /// <param name="wDoc">返回的Word.Document对象</param>  
        /// <param name="WApp">返回的Word.Application对象</param>  
        /// <returns></returns>  
        public static bool CreateNewWordDocument(string templateName, ref Word.Document wDoc, ref  Word.Application WApp)
        {
            Word.Document thisDocument = null;
            Word.Application thisApplication = new Word.ApplicationClass();
            thisApplication.Visible = false;
            thisApplication.Caption = "";
            thisApplication.Options.CheckSpellingAsYouType = false;
            thisApplication.Options.CheckGrammarAsYouType = false;

            Object Template = templateName;// Optional Object. The name of the template to be used for the new document. If this argument is omitted, the Normal template is used.
            Object NewTemplate = false;// Optional Object. True to open the document as a template. The default value is False.
            Object DocumentType = Word.WdNewDocumentType.wdNewBlankDocument; // Optional Object. Can be one of the following WdNewDocumentType constants: wdNewBlankDocument, wdNewEmailMessage, wdNewFrameset, or wdNewWebPage. The default constant is wdNewBlankDocument.
            Object Visible = true;//Optional Object. True to open the document in a visible window. If this value is False, Microsoft Word opens the document but sets the Visible property of the document window to False. The default value is True.

            try
            {
                Word.Document wordDoc = thisApplication.Documents.Add(ref Template, ref NewTemplate, ref DocumentType, ref Visible);

                thisDocument = wordDoc;
                wDoc = wordDoc;
                WApp = thisApplication;
                return true;
            }
            catch (Exception ex)
            {
                string err = string.Format("创建Word文档出错,错误原因:{0}", ex.Message);
                throw new Exception(err, ex);
            }
        }
开发者ID:hijushen,项目名称:WindowDemo,代码行数:36,代码来源:WordHelper1.cs


示例19: initTaskPane

 public void initTaskPane(Word.Document document)
 {
     TaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(
     //                new Controls.LogicTaskPaneUserControl(model, Globals.ThisAddIn.Application.ActiveDocument ),
         new Controls.LogicTaskPaneUserControl(model, document),
         "FabDocx Logical Structure");
     TaskPane.Width = 420;
 }
开发者ID:plutext,项目名称:OpenDoPE-NoXML-WordAddIn,代码行数:8,代码来源:FabDocxState.cs


示例20: AddDetailsControl

 protected Wd.ContentControl AddDetailsControl(Wd.Range range)
 {
     var detailsControl = range.ContentControls.Add_Safely(Wd.WdContentControlType.wdContentControlText);
     detailsControl.Title = control.Title + " Details";
     detailsControl.Tag = control.Tag.Remove(" Delivery") + " Details";
     return detailsControl;
 }
开发者ID:beachandbytes,项目名称:GorillaDocs,代码行数:7,代码来源:Delivery.cs



注:本文中的Microsoft.Office.Interop.Word类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Word.Application类代码示例发布时间:2022-05-24
下一篇:
C# Interop.Visio类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap