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