我正在尝试使用VBA调整文本框大小。为此,我每次都会更改VBA中的矩形编号,这并不符合VBA的目的。
我需要根据其他单元格中的值调整所选文本框的大小。
Sub ResizeTextBox()
Dim shp As Shape
Set shp = ActiveSheet.Shapes("Rectangle 39")
shp.Height = Application.CentimetersToPoints(Range("Y5").Value)
shp.Width = Application.CentimetersToPoints(Range("Y6").Value)
End Sub
如何根据单元格Y5
和Y6
中的值调整选定文本框的大小
发布于 2020-03-02 01:31:37
你可以这样做:
Sub ResizeTextBox()
Dim shp As Shape
'check a range is not selected
If TypeName(Selection) <> "Range" Then
With Selection
.Height = Application.CentimetersToPoints(Range("Y5").Value)
.Width = Application.CentimetersToPoints(Range("Y6").Value)
End With
Else
MsgBox "First select a a shape for resizing"
End If
End Sub
https://stackoverflow.com/questions/60472585
复制相似问题