我想将图像复制到 Word 中的 ActiveX 图像控件。
我认为可以通过 .InlineShapes(index) 来完成,但我只有控件的名称..
Private Sub CommandButton13_Click()
Dim intNoOfRows
Dim intNoOfColumns
Dim objWord
Dim objDoc
Dim objRange
Dim objTable
Dim s As Word.InlineShape
Dim shp As Shape
intNoOfRows = 4
intNoOfColumns = 2
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add
Set objRange = objDoc.Range
objDoc.Tables.Add objRange, intNoOfRows, intNoOfColumns
Set objTable = objDoc.Tables(1)
objTable.Borders.Enable = True
objTable.Cell(1, 1).Range.InlineShapes.AddPicture UserForm1.txtImageLogo
objTable.Cell(1, 2).Range.ParagraphFormat.Alignment = wdAlignParagraphRight
objTable.Cell(1, 2).Range.InlineShapes.AddPicture UserForm1.txtImageLogoClient
objTable.Cell(2, 1).Merge MergeTo:=objTable.Cell(2, 2)
objTable.Cell(2, 1).Height = 520
With objWord
Set s = objTable.Cell(2, 1).Range.InlineShapes.AddPicture(UserForm1.txtImageBackground)
s.Height = 510
s.Width = 460
End With
objTable.Cell(3, 1).Merge MergeTo:=objTable.Cell(3, 2)
objTable.Cell(3, 1).Range.Text = "Prepared by:" & " " & UserForm1.txtPrepared
objTable.Cell(4, 1).Merge MergeTo:=objTable.Cell(4, 2)
objTable.Cell(4, 1).Range.ParagraphFormat.Alignment = wdAlignParagraphRight
objTable.Cell(4, 1).Range.Text = "Belgrade," & " " & Format(Date, "MMMM DD, YYYY ")
Set objTable = Nothing
End Sub
所以,我已经成功地将表格插入到 word 中,一切正常,但我只需要将 backgroundImage 放在文本后面。
谢谢!