[英]How to copy data from Excel to Word doc through VBA?
我正在尝试将数据从excel文件复制到word文件作为屏幕截图。 但是问题在于粘贴的数据非常小。 在复制时或粘贴后,是否可以增加其大小? 以下是我编写的代码。 提前致谢。
Range("A" & startRow & ":G" & endRow).Select
Selection.Copy
With WordApp
.Selection.PasteSpecial Link:=False, DisplayAsIcon:=False, _
DataType:=wdPasteMetafilePicture, Placement:=wdInLine
.Selection.TypeParagraph
.Selection.Orientation = wdTextOrientationVertical
End With
复制形状后,您可以调整其大小,因为它是您最后构建的形状。
这是您可以添加的代码:
Dim oShape As Word.InlineShape
Dim i As Integer
i = ActiveDocument.InlineShapes.Count
' set oShape to the LAST inlineshape
Set oShape = ActiveDocument.InlineShapes(i)
With oShape
' examples only - scale to 90%
.ScaleHeight = 90
.ScaleWidth = 90
' * * * etc etc etc * * * *
End With
Set oShape = Nothing
并且您可以简化Excel代码,因为在复制之前不必选择:
Range("A" & startRow & ":G" & endRow).Copy
足够
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.