如何调整Word文档中图片的大小?
How to resize an image in a Word document?
从Excel开始,打开一个Word文档,在当前位置粘贴一张图片,然后调整它的大小。
我尝试在 InlineShapes.AddPicture
的末尾使用高度命令。
这是插入图片的代码。
Sub CreateWordDocWithPicture()
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
DocDirectory = "C:\Documents\"
Set wdApp = CreateObject("Word.Application") 'Create an instance of word
Set wdDoc = wdApp.Documents.Open(DocDirectory & "Template.docx", ReadOnly:=True)
'Open word file
wdApp.Visible = True
wdApp.Selection.InlineShapes.AddPicture Filename:=DocDirectory & "Image.jpg", LinkToFile:=False, SaveWithDocument:=True
End Sub
例如:
Sub CreateWordDocWithPicture()
Dim wdApp As New Word.Application, wdDoc As Word.Document, wdIshp As Word.InlineShape
Const DocDirectory As String = "C:\Documents\"
With wdApp
.Visible = True
'Open word file
Set wdDoc = .Documents.Open(DocDirectory & "Template.docx", ReadOnly:=True)
With wdDoc
'Insert the image
Set wdIshp = .InlineShapes.AddPicture(FileName:=DocDirectory & "Image.jpg", _
LinkToFile:=False, SaveWithDocument:=True, Range:=.Range.Characters.Last)
'Resize the image
With wdIshp
.LockAspectRatio = True
.Height = InchesToPoints(1.5)
End With
End With
End With
End Sub
从Excel开始,打开一个Word文档,在当前位置粘贴一张图片,然后调整它的大小。
我尝试在 InlineShapes.AddPicture
的末尾使用高度命令。
这是插入图片的代码。
Sub CreateWordDocWithPicture()
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
DocDirectory = "C:\Documents\"
Set wdApp = CreateObject("Word.Application") 'Create an instance of word
Set wdDoc = wdApp.Documents.Open(DocDirectory & "Template.docx", ReadOnly:=True)
'Open word file
wdApp.Visible = True
wdApp.Selection.InlineShapes.AddPicture Filename:=DocDirectory & "Image.jpg", LinkToFile:=False, SaveWithDocument:=True
End Sub
例如:
Sub CreateWordDocWithPicture()
Dim wdApp As New Word.Application, wdDoc As Word.Document, wdIshp As Word.InlineShape
Const DocDirectory As String = "C:\Documents\"
With wdApp
.Visible = True
'Open word file
Set wdDoc = .Documents.Open(DocDirectory & "Template.docx", ReadOnly:=True)
With wdDoc
'Insert the image
Set wdIshp = .InlineShapes.AddPicture(FileName:=DocDirectory & "Image.jpg", _
LinkToFile:=False, SaveWithDocument:=True, Range:=.Range.Characters.Last)
'Resize the image
With wdIshp
.LockAspectRatio = True
.Height = InchesToPoints(1.5)
End With
End With
End With
End Sub