本文整理汇总了C#中Microsoft.Office.Interop.Word.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Office.Interop.Word.Select方法的具体用法?C# Microsoft.Office.Interop.Word.Select怎么用?C# Microsoft.Office.Interop.Word.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Office.Interop.Word
的用法示例。
在下文中一共展示了Microsoft.Office.Interop.Word.Select方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: create
/// <summary>
/// テキストの変更箇所を識別する。
/// </summary>
/// <param name="range">変更箇所のレンジ</param>
/// <returns>テキストの変更箇所</returns>
public static new RevPos create(Word.Range range)
{
Word.Selection selection = range.Application.Selection;
Position start = new Position(0, 0);
Position end = new Position(0, 0);
range.Select();
//終了ページと開始位置の取得
start.fHeight
= range.get_Information(Word.WdInformation.wdVerticalPositionRelativeToPage);
end.fPage
= range.get_Information(Word.WdInformation.wdActiveEndPageNumber);
//終了位置の取得
int ret = selection.MoveStart(Word.WdUnits.wdCharacter, range.End - range.Start);
if (ret == 0) {
throw new System.Exception();
}
//ヘッダだとエラーコードが-1になる。
float posInThePage = selection.get_Information(Word.WdInformation.wdVerticalPositionRelativeToPage);
//ヘッダー以外の場合
if (posInThePage != -1) {
end.fHeight = posInThePage + selection.Font.Size * 1.5F;
}
//ヘッダーの場合
else {
end.fHeight = range.Document.PageSetup.TopMargin - 5.0F;
}
range.Select();
//開始ページ番号取得
selection.MoveEnd(Word.WdUnits.wdCharacter, range.Start - range.End);
start.fPage
= selection.get_Information(Word.WdInformation.wdActiveEndPageNumber);
return new RevPosOfText(start, end, range);
}
示例2: CheckRefferenceError
/// <summary>
/// 参照エラーのチェック
/// </summary>
/// <param name="doc">Document</param>
public void CheckRefferenceError(Word.Document doc)
{
doc.Select();
doc.Application.Selection.Find.ClearFormatting();
Word.Find findObject = doc.Application.Selection.Find;
findObject.Text = "エラー! 参照元が見つかりません。";
findObject.Forward = true;
findObject.Execute();
while (findObject.Found) {
fApp.Selection.Comments.Add(fApp.Selection.Range, "【警告】参照エラー");
findObject.Execute();
}
}
示例3: create
/// <summary>
/// 図の変更箇所を識別する。
/// </summary>
/// <param name="range">変更箇所のレンジ</param>
/// <returns>図の変更箇所</returns>
public static new RevPos create(Word.Range range)
{
Word.Selection selection = range.Application.Selection;
Position start = new Position(0, 0);
Position end = new Position(0, 0);
//終了ページと開始位置の取得
start.fHeight = range.get_Information(Word.WdInformation.wdVerticalPositionRelativeToPage);
end.fPage = range.get_Information(Word.WdInformation.wdActiveEndPageNumber);
end.fHeight = range.get_Information(Word.WdInformation.wdVerticalPositionRelativeToPage);
//図の大きさ分だけ終了位置を移動
range.Select();
foreach (Word.InlineShape shp in selection.InlineShapes) {
end.fHeight += shp.Height;
}
//開始ページ番号取得
selection.MoveEnd(Word.WdUnits.wdCharacter, range.Start - range.End);
start.fPage = selection.get_Information(Word.WdInformation.wdActiveEndPageNumber);
return new RevPosOfFigure(start, end, range);
}
示例4: highlight
public static void highlight(Word.Range range)
{
range.Select();
//range.HighlightColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdGray25;
}
示例5: ProcessWordField
private static void ProcessWordField(Dictionary<string, string> dictionary, Word.Field field, Word.Application word)
{
object missing = Type.Missing;
foreach (var key in dictionary.Keys)
{
if (field.Code.Text.IndexOf("MERGEFIELD " + key) > -1)
{
string value = dictionary[key];
if (String.IsNullOrEmpty(value) == true)
{
field.Code.Text = String.Empty;
break;
}
if (key.IndexOf("PICTURE") > -1)
{
try
{
field.Select();
word.Selection.InlineShapes.AddPicture(value, ref missing, ref missing, ref missing);
TryToDeleteTmpFile(value);
}
catch (Exception) { Logger.Echo("Insert picture error !!!"); }
}
else
{
field.Select();
word.Selection.TypeText(value);
}
break;
}
}
}
示例6: InsertText
private static void InsertText(Word.Field field, Word.Application word, string text)
{
field.Select();
word.Selection.TypeText(text);
}
示例7: InsertPicture
private static void InsertPicture(Word.Field field, Word.Application word, string file, bool scale = true)
{
try
{
object missing = Type.Missing;
const int maxWidth = 100;
const int maxHeight = 100;
field.Select();
var picture = word.Selection.InlineShapes.AddPicture(file, ref missing, ref missing, ref missing);
if (scale == true)
{
if (picture != null)
{
if (picture.Width > maxWidth) { picture.Width = maxWidth; }
if (picture.Height > maxHeight) { picture.Height = maxHeight; }
}
}
}
catch (Exception) { Logger.Echo("Insert picture error !!!"); }
}