如题!开源无人机地面站培训教材。默认A4纸打印!
文档地址:
链接:https://pan.baidu.com/s/1Jvvssyezr4HUrJr_8UQ8aQ
提取码:3zi8
复制这段内容后打开百度网盘手机App,操作更方便哦
图片自动调整的宏:《图片按页宽等比缩放》
链接:https://pan.baidu.com/s/1GwjHWouc6UKrI4iVfxBiCg
提取码:qwdi
复制这段内容后打开百度网盘手机App,操作更方便哦
宏代码:2.54即页边距;29.7X21即A4纸的大小;根据需要自己调整(VBA自学的,没搞明白怎么自动获取这些值,知道的欢迎回贴!3Q)
-----------------------------------------------------------------------------------------------------------------
Sub 图片按页宽等比缩放()
Dim n '图片个数
Dim myShape As Variant
Dim picheight
Dim picwidth
Dim pheight
Dim pwidth
On Error Resume Next '忽略错误
Set doc = ActiveDocument
pheight = CentimetersToPoints(29.7 - 2.54 - 2.54)
pwidth = CentimetersToPoints(21 - 2.54 - 2.54)
MsgBox "InlineShape = " & doc.InlineShapes.Count & _
vbCr & "Shapes = " & doc.Shapes.Count
For n = 1 To doc.InlineShapes.Count 'InlineShapes类型图片
Set myShape = doc.InlineShapes(n)
myShape.LockAspectRatio = msoTrue
picheight = myShape.Height / myShape.ScaleHeight * 100
picwidth = myShape.Width / myShape.ScaleWidth * 100
If picheight > pheight Or picwidth > pwidth Then
If picheight / pheight > picwidth / pwidth Then
myShape.ScaleHeight = Fix(pheight / picheight * 100)
Else
myShape.ScaleWidth = Fix(pwidth / picwidth * 100)
End If
Else
myShape.ScaleHeight = 100
myShape.ScaleWidth = 100
End If
Next n
End Sub
|