<pre> public static bool FindLineSpacingInParagraph(IQuestion question, string filename, int paragraph, float lineSpacing) { WordInterop.Application wordApplication = GetOrCreateWordApplication(question.ObjectStore); try { //Avoid screen flickering or unwanted alerts while initializing wordApplication.ScreenUpdating = false; WordInterop.WdAlertLevel displayAlertLevel = wordApplication.DisplayAlerts; wordApplication.DisplayAlerts = WordInterop.WdAlertLevel.wdAlertsNone; WordInterop.Document wordDocument = wordApplication.Documents.Open(filename); if (paragraph >= wordDocument.Paragraphs.Count) return false; WordInterop.Paragraph paragraphObject = wordDocument.Paragraphs[paragraph]; if (paragraphObject == null) return false; bool result = paragraphObject.LineSpacing == lineSpacing;//LineSpacing=13.5 object save_changes = false; object missing = Type.Missing; wordDocument.Close(ref save_changes, ref missing, ref missing); return result; } catch (Exception) { Cleanup(question.ObjectStore, true); } return false; }
Selection.ParagraphFormat.LineSpacingRule = WdLineSpacing.wdLineSpaceSingle;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)