VBA-EXCEL:控制WORD指定位置,插入图片并调整在大小,高低,环绕

Dim WordApp As Object
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
Dim WordDoc As Object
Set WordDoc = WordApp.Documents.Open(ThisWorkbook.Path & "\TEST.docx")

PicPath="图片地址"
WordApp.ActiveDocument.Bookmarks("BM1_1").Range.Select 'Word里定义书签BM1_1
Set Pic = WordApp.Selection.InlineShapes.AddPicture(Filename:=PicPath, SaveWithDocument:=True) '插入图片
Set Shape = Pic.ConvertToShape '转为Shape后才可以调整
Shape.Top = Shape.Top + 10
Shape.Left =  10
Shape.Width = 10
Shape.Height = 10

'嵌入式  -未验证
Shape.WrapFormat.Type = wdWrapTight '紧密环绕

'wdWrapInline 嵌入式
'wdWrapNone 改为默认
'wdWrapSquare 四周环绕
'wdWrapThrough 穿越环绕
'wdWrapTopBottom 上下环绕

因为要用到Word中的一些常规变量,所以需要引用Microsoft Word 16.0 Object Library  (版本号16因各人PC中安装的版本不同)

你可能感兴趣的:(VBA,OFFICE-EXCEL,WORD)