2016-08-16 80 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文档更好,所以我留下了链接。 –