Sub ResizeImagesToPageWidth() Application.ScreenUpdating = True ' 获取当前文档 Set doc = ActiveDocument ' 获取页面宽度并减去页边距 With doc.PageSetup pgWidth = .PageWidth - .LeftMargin - .RightMargin End With ' 遍历所有嵌入型图片 For Each shp In doc.InlineShapes ' 计算图片的宽高比 aspectRatio = Abs(shp.Height / shp.Width) pgHeight = pgWidth * aspectRatio ' 调整图片宽度为页面宽度 ' shp.LockAspectRatio = msoTrue shp.Width = pgWidth shp.Height = pgHeight ' 根据宽高比调整图片高度 shp.Height = shp.Width * aspectRatio Next shp MsgBox "所有图片已调整为页面宽度!" End Sub
标签:shp,doc,Height,适应,Width,pgWidth,图片大小,页面 From: https://www.cnblogs.com/love-DanDan/p/18213335