如何在宏中的Selection.PasteSpecial操作后调整图片大小(增强的图元文件)(Word 2007) [英] How do i Resize a Picture (enchanced Metafile) after a Selection.PasteSpecial operation in a macro (word 2007)

查看:529
本文介绍了如何在宏中的Selection.PasteSpecial操作后调整图片大小(增强的图元文件)(Word 2007)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述






你好,


我可以在这个问题上做一些帮助,经过详尽的搜索2个小时我还是找不到解决方案。基本上我有很多Excel表格需要粘贴到报表中,我有
一个宏将它们粘贴为增强型图元文件。但我还想在同一个功能中调整这些图片的大小。


问题在于"选择"。 PasteSpecial的"函数不返回我要处理的对象标识符,使用以下行将无法工作,因为粘贴的对象是当前未选中的



< pre class ="prettyprint"style =""> Selection.InlineShapes(1).Width = CentimetersToPoints(9)


该行将返回"该集合的请求成员不存在"。


我找到了索引数字的方法文档中的InlineShapes,但同样,只有当它是文档中的最后一个时才会起作用,因此它不会引用正确的图片。


 Sub pasteEnchMeta()
'pasteEnchMeta Macro
Dim PasteObect As InlineShape
Dim Count As Integer    

Selection.PasteSpecial Link:= False,DataType:= wdPasteEnhancedMetafile,_Placement:= wdInLine,DisplayAsIcon:= False  

Count = ActiveDocument.InlineShapes.Count  
设置PasteObect = ActiveDocument.Content.InlineShapes(Count)  

使用PasteObect  
.Width = CentimetersToPoints(9)  
结束时间  &NBSP;

End Sub





如何才能调整刚刚粘贴的增强型图元文件?


非常感谢任何帮助。




解决方案

你是如何使用选择的。


我对单词对象模型不太自信。但我认为单词索引按文档中的位置。如果你经常向下/向上看,那么我认为它可以在你的代码中使用。


但是如果你的选择是随机的那么它可能是不可行的。







Hi there,

I could really do with some help on this one, After exhaustive searching for 2 hours I still cannot find the solution. Basically I have lots of Excel Tables i need to paste into a report, and I have a Macro that will paste these as Enhanced Metafiles. But I would also like to resize these pictures in the same function.

The problem is that the "Selection.PasteSpecial" function does not return an object identifier for me to handle, using the following line will not work either because the object that is pasted is not currently selected.

Selection.InlineShapes(1).Width = CentimetersToPoints(9)

the line will return "The Requested member of the collection does not exist".

I found a way to index the number of InlineShapes in the document, but again, this will only work if its the last one in the document, so its not referencing the correct Picture.

Sub pasteEnchMeta()
' pasteEnchMeta Macro
Dim PasteObect As InlineShape
Dim Count As Integer     

Selection.PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafile, _Placement:=wdInLine, DisplayAsIcon:=False   

Count = ActiveDocument.InlineShapes.Count   
Set PasteObect = ActiveDocument.Content.InlineShapes(Count)   

With PasteObect   
.Width = CentimetersToPoints(9)   
End With   

End Sub


What can I do to be able to resize the Enhanced metafile that I have just pasted?

Any help would be very much appreciated.


解决方案

How you are using selection.

I am not so confident with word object model.But I think word indexes by position in document.If you constantly go downwards/upawards then I think it is possible in your code.

But if your selection is random then it is probably not doable.


这篇关于如何在宏中的Selection.PasteSpecial操作后调整图片大小(增强的图元文件)(Word 2007)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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