[英]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.