2016-08-16 72 views
0

我想替換mergefiled與圖像 ,我做到了。 現在我想要移動圖像有點像在MS單詞中使用鼠標。 我該怎麼做? 這是我的代碼。我怎樣才能移動圖像以毫秒字使用C#

//hash = values for find, field = mergefields in word document 
foreach (string s in hash.Keys)//if (hash key == field) 
      { 
       hashVal = hash[s].ToString(); 


       Find findObj = app.Selection.Find; 

       findObj.ClearFormatting(); 
       findObj.Text = frontM + fdName + backM; //=mergeField 


       if (findObj.Text.Equals(frontM + s + backM)) 
       { 
        merge.Select(); 
        app.Selection.TypeBackspace(); 


        word.InlineShapes.AddPicture(hashVal, true, false, app.Selection.Range).ConvertToShape().WrapFormat.Type = WdWrapType.wdWrapFront; 
        //app.Selection.MoveUp(); ???????? 
       } 
      } 

回答

0

您可以使用Relocate method如下:

rangeToMove.Relocate(WdRelocate.wdRelocateUp); 

的細節和更多的例子見VBA documentation

+0

感謝您的評論,是否有可能在C#?它似乎爲VBA – Hee

+0

我稍微替換了示例。 VBA文檔更好,所以我留下了鏈接。 –