如何在EXCEL中复制区域,然后使用宏在Word中调整大小并粘贴 [英] How to copy a range in excel and then resize and paste in word with a macro
本文介绍了如何在EXCEL中复制区域,然后使用宏在Word中调整大小并粘贴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Sub CopyToWord()
Dim objWord As New Word.Application
'copying the range that I want to paste in Word
With ThisWorkbook.Worksheets("grid_copy")
.Range("b1:AA42").CopyPicture xlScreen
End With
'pasting the picture in a new Word document
With objWord
.Documents.Add
.Selection.Paste
.Selection.ShapeRange.Height = 651
.Selection.ShapeRange.Width = 500
'Those two lines don't work to resize the picture that i'm pasting in word
.Visible = True
End With
End Sub
代码实际工作正常,但我无法应用我想要的图像大小调整。你们知道有什么方法可以从Excel的范围中调整我粘贴到Word中的图片的大小吗?
推荐答案
尝试:
Sub CopyToWord()
'copying the range that I want to paste in Word
ThisWorkbook.Worksheets("grid_copy").Range("b1:AA42").CopyPicture xlScreen
'pasting the picture in a new Word document
Dim wdApp As New Word.Application, wdDoc As Word.Document, wdImg As Word.InlineShape
With wdApp
.Visible = True
.ScreenUpdating = False
Set wdDoc = .Documents.Add
With wdDoc
.Range.Paste
Set wdImg = .InlineShapes(1)
With wdImg
.Height = 651
.Width = 500
End With
End With
.ScreenUpdating = True
End With
End Sub
这篇关于如何在EXCEL中复制区域,然后使用宏在Word中调整大小并粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文