如何使用书签从单词中获取自动整形? [英] How to get autoshape from word using bookmark?

查看:100
本文介绍了如何使用书签从单词中获取自动整形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


从Word(2007)文档复制形状时遇到问题.如何使用书签从单词复制形状?有人可以帮我吗?
这就是我在做什么:


Hi
I am facing problem while copying a shape from word(2007) document. How to copy a shape from word using bookmark? Could some one help me?
This is what i am doing:


object FileName = objTemplateFile;
object oMissing = System.Reflection.Missing.Value;                    
object oWhat = WdGoToItem.wdGoToBookmark;
object oName = "MyBookmark";
//Opening source document in hidden mode
objWord = wordApp.Documents.Open(ref FileName, ref oFalse, ref oTrue, ref oFalse, ref oMissing, ref oMissing, ref oMissing,ref oMissing, ref oMissing, ref oMissing, ref oFalse, ref  oFalse, ref oMissing, ref oTrue, ref oMissing, ref oMissing);

objWord.Bookmarks.get_Item(ref oName).Range.Select();
objWord.Range(ref oMissing, ref oMissing).Copy();
//Copy the shape in to target dc
wordApp.ActiveWindow.Selection.Paste();      

推荐答案

似乎您正确地找到了书签,但是又错误地将其复制.您正在选择(突出显示)书签的内容,但是实际上是复制不同范围的内容(当您进入objWord.Range(ref oMissing, ref oMissing)时,您基本上是在识别整个文档主体,因为您没有指定开始位置和结束位置.

我认为正确的代码应为:
Seems that you''re finding the bookmark correctly, but then copying it wrong. You''re selecting (highlighting) the contents of the bookmark, but then actually copying the contents of a different range (when you go objWord.Range(ref oMissing, ref oMissing) you''re basically identifying the entire document body, because you didn''t specify the start and end positions).

I think the correct code would be:
objWord.Bookmarks.get_Item(ref oName).Range.Copy(); // Copy range directly instead of selecting it and then trying to copy it

//Copy the shape in to target dc
wordApp.ActiveWindow.Selection.Paste();


这篇关于如何使用书签从单词中获取自动整形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆