400-099-0376

在线试用
微信扫码联系专属客服
安企神软件官网
首页
下载中心
客户列表
关于安企神

vba设置word图片格式

2024-10-31

一、旋转图片

Dim blnIsInlineShape As Boolean

If Selection.Type = wdSelectionInlineShape Then

blnIsInlineShape = True

Selection.InlineShapes(1).ConvertToShape

End If

Dim intTurn As Integer

intTurn = InputBox("请输入图形要旋转的角度值" & vbCrLf & "正数表示顺时针,负数表示逆时针。", "图形旋转", 30)

Selection.ShapeRange.IncrementRotation intTurn

End Sub

二、将文档中的每张图片的版式转换为嵌入式图形

For Each s In Documents("MyDoc.doc").Shapes

If s.Type = msoPicture Then

s.ConvertToInlineShape

End If

Next s

三、设置图片的高度宽度

Mywidth=10'10为图片宽度(厘米)

Myheigth=10'10为图片高度(厘米)

For Each iShape In ActiveDocument.InlineShapes

iShape.Height = 28.345 * Myheigth

iShape.Width = 28.345 * Mywidth

Next iShape

四、得到图片的像素

Sub 获取嵌入型图片的像素()

On Error Resume Next

With Selection.Range.Find

.ClearFormatting

.Replacement.ClearFormatting

.Execute findtext:="^g", MatchWildcards:=False, Wrap:=wdFindStop

MsgBox "该图片的像素为:" & Selection.InlineShapes(1).Width _

& " * " & Selection.InlineShapes(1).Height

End With

End Sub

五、复制图片到word文档中

Dim objWordApp As Word.Application

Dim objWord As Word.Document

Range(Cells(3, 2), Cells(11, 11)).Select

Selection.CopyPicture

Set objWordApp = CreateObject("Word.Application")

Set objWord = objWordApp.Documents.Add

objWord.Application.Visible = True

objWord.Application.Selection.Paste

Set objWord = Nothing

Set objWordApp = Nothing

  • TAG: