vba - Word 宏 - 无需调整大小即可获取原始大小
问题描述
我想要一个宏来检查嵌入的 OLEObjects 的大小与它们的原始尺寸。当您尝试获取 Shapes 或 InlineShapes 的缩放属性时,您会得到无意义的数字(例如 0 ),因此我最终的解决方法是检查它们的大小,然后将大小调整为原始大小的 100%,然后检查该大小并进行比较。有没有更好的办法?
For Each shp In ActiveDocument.Shapes
If shp.Type = msoEmbeddedOLEObject Then
sW = shp.Width
sH = shp.Height
shp.ScaleWidth 1#, msoTrue
shp.ScaleHeight 1#, msoTrue
sW = sW / shp.Width
sH = sH / shp.Height
shp.ScaleWidth sW, msoTrue
shp.ScaleHeight sH, msoTrue
End If
Next
For Each ishp In ActiveDocument.InlineShapes
If ishp.Type = wdInlineShapeEmbeddedOLEObject Then
sW = ishp.Width
sH = ishp.Height
ishp.ScaleWidth = 100
ishp.ScaleHeight = 100
sW = sW / ishp.Width
sH = sH / ishp.Height
ishp.ScaleWidth = sW * 100
ishp.ScaleHeight = sH * 100
End If
Next
解决方案
推荐阅读
- python - 在 Python 中使用 addfips 将 FIPS 代码添加到 csv
- arrays - 打印或保存 tp csv 带有 unicode 字符和额外字段的 json 文件
- c# - 回复地址与请求授权时提供的回复地址不符
- c++ - c ++:在if-else条件中定义数组在退出后会擦除
- javascript - 使用 Mongoose 将 ObjectId 作为字符串保存到 MongoDB 失败
- macos - 在 Ubuntu 的远程 ssh 会话上(本地是 Mac OS 计算机),为什么当我键入“bash”时颜色会出现?
- android - RecyclerView 为列表中的每个项目使用不同的 ItemTouchHelper
- r - 闪亮的滑块未更新
- ruby-on-rails - 如何更新我的 Ruby on Rails 生产服务器
- python - Maya Python,重命名关节:多个对象匹配名称