本文介绍了如何使用interop C#评估worddocument中的tabstops?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 大家好, 我的Windows应用程序具有Microsoft Word互操作性c#。 此应用程序用于评估用户在ms-word中完成的操作。 我必须创建一个模板来评估word文档中使用的Paragraph TabStops。 我尝试过: wordApplication.ScreenUpdating =假; WordInterop.WdAlertLevel displayAlertLevel = wordApplication.DisplayAlerts; wordApplication.DisplayAlerts = WordInterop.WdAlertLevel.wdAlertsNone; WordInterop.Document wordDocument = wordApplication.Documents.Open(filename); bool result = false; WordInterop.Range range = wordDocument.Paragraphs [paragraph] .Range; WordInterop.Paragraph wdParagraph = wordDocument.Paragraphs [paragraph]; var abc = wordDocument.Paragraphs [paragraph] .Format.TabStops; foreach(在abc中的WordInterop.TabStops t) { t.position; //如果(t.position == 1.5,我没有获得一个tabstop 的位置) ) result = true; } wordDocument.Close(); 返回结果; 我无法获得段落的tabStop的位置。 任何人都可以帮助我。 谢谢解决方案 替换: foreach(在abc中的WordInterop.TabStops t) with: foreach(WordInterop.TabStop t in abc ) NB: TabStop ,没有尾随s。 TabStop界面(Microsoft.Office.Interop.Word) | Microsoft Docs [ ^ ] Hi Guys,I have windows application with Microsoft word interoperability c#.This application is used to Evaluate Actions done in ms-word by a user.I have to create one template to Evaluate Paragraph TabStops used in the word document.What I have tried:wordApplication.ScreenUpdating = false;WordInterop.WdAlertLevel displayAlertLevel = wordApplication.DisplayAlerts;wordApplication.DisplayAlerts = WordInterop.WdAlertLevel.wdAlertsNone;WordInterop.Document wordDocument = wordApplication.Documents.Open(filename);bool result = false;WordInterop.Range range = wordDocument.Paragraphs[paragraph].Range;WordInterop.Paragraph wdParagraph = wordDocument.Paragraphs[paragraph];var abc = wordDocument.Paragraphs[paragraph].Format.TabStops;foreach(WordInterop.TabStops t in abc){ t.position;// i'm not getting the position of a tabstop if(t.position == 1.5) result = true;} wordDocument.Close();return result;I'm not able to get the position of a tabStop of a paragraph.Can anyone please help me.Thanks 解决方案 Replace: foreach(WordInterop.TabStops t in abc)with: foreach(WordInterop.TabStop t in abc)NB: TabStop, without the trailing "s".TabStop Interface (Microsoft.Office.Interop.Word) | Microsoft Docs[^] 这篇关于如何使用interop C#评估worddocument中的tabstops?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-23 09:52