繁体   English   中英

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

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

我想用图像替换mergefiled,我做到了。 现在我想将图像向上移动一点,就像在ms word中使用鼠标一样。 我怎样才能做到这一点? 这是我的代码。

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

您可以使用Relocate方法 ,如下所示:

rangeToMove.Relocate(WdRelocate.wdRelocateUp);

有关详细信息和更多示例,请参见VBA文档

暂无
暂无

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

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