【发布时间】:2018-07-23 00:02:12
【问题描述】:
我有一个表单,要求 1 个字符串作为文件名,1 个长字符串作为 CenterHeader 中使用的数字。
我已经让它正确地执行上述任务。但是,我希望进一步编辑/格式化 CenterHeader 中的文本(粗体、字体等......)。我似乎无法弄清楚如何正确引用它
Private Sub Export_Click()
Application.DisplayAlerts = False
Worksheets("Shelter Run").Copy
With ActiveWorkbook
Dim sht As Worksheet
Set sht = Worksheets(1)
sht.PageSetup.CenterHeader = "Shelter Run#" & TextBox1.Value
'sht.PageSetup.CenterHeader.Address.Bold = True
.SaveAs Filename:="C:\random\dir" & TextBox2.Value & ".xlsx", FileFormat:=xlOpenXMLStrictWorkbook, CreateBackup:=False
.Close False
End With
Application.DisplayAlerts = True
MsgBox TextBox2.Value & ".xlsx has been created!"
Unload Me
End Sub
【问题讨论】:
-
你试过宏记录器吗?
-
是的,给我 selection.font.bold