简体   繁体   English

我如何使用C#在MS Word中移动图像

[英]How can i move image in ms word using c#

i want replace mergefiled with image and i did that. 我想用图像替换mergefiled,我做到了。 now I want to move image up a bit like using mouse in ms word. 现在我想将图像向上移动一点,就像在ms word中使用鼠标一样。 how can i do that? 我怎样才能做到这一点? here is my code. 这是我的代码。

//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(); ????????
                }   
            }

You can use Relocate method as follows: 您可以使用Relocate方法 ,如下所示:

rangeToMove.Relocate(WdRelocate.wdRelocateUp);

See VBA documentation for details and more examples. 有关详细信息和更多示例,请参见VBA文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM