0
我有用于更改形状大小的VBA代码,但是我想将数字转换为cm。有关如何转换这些数字的任何建议?
另一个问题是,我想改变多个选定形状的相同大小;你能帮我解决这个问题吗?将形状大小转换为cm
非常感谢!
Sub test()
Dim objHeigh As Integer
Dim objWidth As Integer
Dim oSh As Shape
On Error GoTo CheckErrors
With ActiveWindow.Selection.ShapeRange
If .Count = 0 Then
MsgBox "You need to select a shape first"
Exit Sub
End If
End With
For Each oSh In ActiveWindow.Selection.ShapeRange
objHeigh = oSh.Height
objWidth = oSh.Width
objHeigh = CInt(InputBox$("Assign a new size of Height", "Heigh", objHeigh))
' give the user a way out
If objHeigh = 0 Then
Exit Sub
End If
If objName <> "" Then
oSh.Name = objName
End If
objWidth = CInt(InputBox$("Assign a new size of Width", "Width", objWidth))
' give the user a way out
If objWidth = 0 Then
Exit Sub
End If
oSh.Height = CInt(objHeigh)
oSh.Width = CInt(objWidth)
Next
Exit Sub
CheckErrors: MsgBox Err.Description
End Sub
好的谢谢。但我应该在哪里分配我的代码中的功能? – Norby
将.e.g放在与test()子模块相同的模块中,然后可以像ConvertCmToPoint(10.5)那样调用它。所以基本上你可以在你的初始代码的“end sub”行下面复制和粘贴功能 – DAXaholic
是的,我知道这一点。对不起,因为Im新的VBA Im混淆了在哪里调用该函数,我应该分配给变量还是?谢谢你的努力! – Norby