|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
网上找的:- Private Sub CommandButton1_Click()
- 'creat by 萧雨 260961242- 2014-05-28
- Dim fd As FileDialog, vrtSelectedItem As Variant, wd As Document, p As InlineShape, w, h
- Application.ScreenUpdating = False
- Set fd = Application.FileDialog(msoFileDialogFilePicker)
- With fd
- .AllowMultiSelect = True
- .InitialFileName = ActiveDocument.Path
- If .Show <> -1 Then
- Application.ScreenUpdating = True
- MsgBox "您没有选择任何文档!", vbOK, "退出"
- Exit Sub
- Else
- w = InputBox("输入要设置的图片宽度(cm)", "输入宽度", 8)
- h = InputBox("输入要设置的图片高度(cm)", "输入宽度", 8)
- For Each vrtSelectedItem In .SelectedItems
- Set wd = Documents.Open(vrtSelectedItem)
- For Each p In wd.InlineShapes
- p.LockAspectRatio = msoFalse '取消锁定纵橫比
- p.Width = Round(w / 2.54 * 72 * 4, 0) / 4 '将磅单位转化成厘米
- p.Height = Round(h / 2.54 * 72 * 4, 0) / 4
- Next
- wd.Close savechanges:=True
- Set wd = Nothing
- Next
- End If
- End With
- Application.ScreenUpdating = True
- MsgBox "图片设置完成!", , "运行完成 @萧260961242"
- End Sub
复制代码 |
|