三、光标移动
-
-
- object unit = Microsoft.Office.Interop.Word.WdUnits.wdLine;
- object count = 3;
- WApp.Selection.MoveEnd(ref unit,ref count);
- WApp.Selection.MoveUp(ref unit, ref count, ref missing);
-
- WApp.Selection.Tables[1].Cell(1, 1).Select();
-
- object unith = Microsoft.Office.Interop.Word.WdUnits.wdRow;
- object extend = Microsoft.Office.Interop.Word.WdMovementType.wdExtend;///extend对光标移动区域进行扩展选择
- object unitu = Microsoft.Office.Interop.Word.WdUnits.wdLine;
- object unitp = Microsoft.Office.Interop.Word.WdUnits.wdParagraph;
- object count=1;
下面代码演示对于存在合并单元格的选择操作.合并单元格的选择问题一直是word的bug.部分object对象参照上面代码
上面这个是表格合并样式.要如何才能选择2行标题栏尼.看下面代码
-
- WApp.Selection.Tables[1].Cell(1, 1).Select();
-
- WApp.Selection.HomeKey(ref unith, ref missing);
-
- WApp.Selection.EndKey(ref unith, ref extend);
-
- object strtitlerow=titlerow-1;
-
- WApp.Selection.MoveDown(ref unitp, ref count, ref extend);
-
- WApp.Selection.MoveDown(ref unitu, ref strtitlerow, ref extend);
-
- WApp.Selection.EndKey(ref unith, ref extend);
-
- WApp.Selection.Copy();
-
- WApp.Selection.Tables[1].Cell(System.Convert.ToInt32(strRownum), 1).Select();
- WApp.Selection.HomeKey(ref unith, ref missing);
- WApp.Selection.Paste();
四、段落格式设定
-
- WApp.Selection.ParagraphFormat.LeftIndent = WApp.CentimetersToPoints(float.Parse("0"));
- WApp.Selection.ParagraphFormat.RightIndent = WApp.CentimetersToPoints(float.Parse("0"));
- WApp.Selection.ParagraphFormat.SpaceBefore =float.Parse("0");
- WApp.Selection.ParagraphFormat.SpaceBeforeAuto =0;
- WApp.Selection.ParagraphFormat.SpaceAfter = float.Parse("0");
- WApp.Selection.ParagraphFormat.SpaceAfterAuto = 0;
- WApp.Selection.ParagraphFormat.LineSpacingRule = Microsoft.Office.Interop.Word.WdLineSpacing.wdLineSpaceSingle;
- WApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphJustify;
- WApp.Selection.ParagraphFormat.WidowControl = 0;
- WApp.Selection.ParagraphFormat.KeepWithNext = 0;
- WApp.Selection.ParagraphFormat.KeepTogether = 0;
- WApp.Selection.ParagraphFormat.PageBreakBefore = 0;
- WApp.Selection.ParagraphFormat.NoLineNumber = 0;
- WApp.Selection.ParagraphFormat.Hyphenation = 1;
- WApp.Selection.ParagraphFormat.FirstLineIndent = WApp.CentimetersToPoints(float.Parse("0"));
- WApp.Selection.ParagraphFormat.OutlineLevel = Microsoft.Office.Interop.Word.WdOutlineLevel.wdOutlineLevelBodyText;
- WApp.Selection.ParagraphFormat.CharacterUnitLeftIndent = float.Parse("0");
- WApp.Selection.ParagraphFormat.CharacterUnitRightIndent = float.Parse("0");
- WApp.Selection.ParagraphFormat.CharacterUnitFirstLineIndent = float.Parse("0");
- WApp.Selection.ParagraphFormat.LineUnitBefore = float.Parse("0");
- WApp.Selection.ParagraphFormat.LineUnitAfter = float.Parse("0");
- WApp.Selection.ParagraphFormat.AutoAdjustRightIndent = 1;
- WApp.Selection.ParagraphFormat.DisableLineHeightGrid =0;
- WApp.Selection.ParagraphFormat.FarEastLineBreakControl =1;
- WApp.Selection.ParagraphFormat.WordWrap = 1;
- WApp.Selection.ParagraphFormat.HangingPunctuation = 1;
- WApp.Selection.ParagraphFormat.HalfWidthPunctuationOnTopOfLine = 0;
- WApp.Selection.ParagraphFormat.AddSpaceBetweenFarEastAndAlpha = 1;
- WApp.Selection.ParagraphFormat.AddSpaceBetweenFarEastAndDigit = 1;
- WApp.Selection.ParagraphFormat.BaseLineAlignment = Microsoft.Office.Interop.Word.WdBaselineAlignment.wdBaselineAlignAuto;
阅读(2090) | 评论(1) | 转发(0) |