針對office的word文檔,先添加宏文件,再運行就可以。
Sub 圖片格式統一() Myheigth = 8 '設置高度 Mywidth = 10 '設置寬度 On Error Resume Next For Each iShape In ActiveDocument.InlineShapes iShape.LockAspectRatio = msoFlase '取消鎖定縱橫比 iShape.Height = 28.345 * Myheigth iShape.Width = 28.345 * Mywidth With iShape .Range.ParagraphFormat.Reset .Range.ParagraphFormat.Alignment = wdAlignParagraphCenter '居中 End With Next For Each Shape In ActiveDocument.Shapes Shape.LockAspectRatio = msoFlase Shape.Height = 28.345 * Myheigth Shape.Width = 28.345 * Mywidth With Shape .Range.ParagraphFormat.Reset .Range.ParagraphFormat.Alignment = wdAlignParagraphCenter '居中 End With Next End Sub