我想检查 Excel2010 文档中是否存在格式样式。
On Error Resume Next
Private Function checkStyleName(ByVal strStyleName As String) As Boolean
Dim objGivenStyle As Excel.Style
Set objGivenStyle = ActiveDocument.Styles(strStyleName) ' try to get formatting style out of list
If objGivenStyle Is Nothing Then
' do something
checkStyleName = False
Else
checkStyleName = True
End If
End Function
问题是,Set objGivenStlye = ActiveDocument.Styles(strStyleName)
根本不起作用。最好的解决方案是什么——也许是所有现有样式的循环?
THX BKS