[英]the code to change font names, size for textbox in Excel macro
try to find the code to change font names, size for textbox in Excel macro, all my codes from " .font.name= to End with" shows wrong in VBA, any suggestions? 尝试找到更改字体名称,Excel宏中文本框大小的代码,我所有的代码从“ .font.name =到结尾为”在VBA中显示错误,有什么建议吗? thanks 谢谢
Set myDocument = Worksheets(1)
Set tx_ = myDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 382, 266, 122, 20)
tx_.TextFrame.Characters.Text = ThisWorkbook.Sheets(1).Cells(6, 8)
With tx_.TextFrame.Characters.Text
.Font.Name = "Tahoma"
.Font.Size = 10
.Font.Bold = msoTrue
End With
Whereas .Text
is a valid property of the .Characters
object, .Font
is not a sub-property of it of some sort. 而.Text
是一个有效的财产.Characters
对象, .Font
是不是它的某种类型的子属性。 It is a property to the object on it's own. 它是对象本身的属性。 Therefor the following worked for me: 因此,以下对我有用:
Sub Tst()
Dim myDocument As Worksheet: Set myDocument = ThisWorkbook.Sheets("Sheet1")
Dim tx As Shape
Set tx = myDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 382, 266, 122, 20)
With tx.TextFrame.Characters
.Text = mydocument.Cells(6, 8)
.Font.Name = "Tahoma"
.Font.Size = 10
.Font.Bold = msoTrue
End With
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.