簡體   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