0
是否有任何简单而通用的方法来确定是否在选定的文本中分配了任何字符样式? 目前我使用的功能,但它并不是独立的微软Word语言版本:Word VBA:在选择内是否有任何字符样式?
Function AnyCharacterStyleAssigned()
'elicit the name of the default paragraph font
V_AppLang = Application.Language
If V_AppLang = 1031 Then
Vst_Default = "Absatz-Standardschriftart"
ElseIf V_AppLang = 1045 Then
Vst_Default = "Domy" & ChrW(347) & "lna czcionka akapitu"
ElseIf V_AppLan = 1033 Then
Vst_Default = "Default Paragraph Font"
Else
MsgBox prompt:="this script doesn't work for this language version of Word", Buttons:=vbOKOnly
End
End If
'search for the default paragraph font within the selection range
Set R_Range = Selection.Range
R_Range.Find.ClearFormatting
R_Range.Find.Style = Vst_Default
R_Range.Find.Execute findtext:="", Forward:=True, Wrap:=wdFindStop, Format:=True
AnyCharacterStyleAssigned = IIf(R_Range.Start >= Selection.End, False, True)
End Function
我不知道该怎么做你的问题。首先,我对你参考WinWord感到吃惊。我不知道VBA和WinWord之间有任何联系,或者WinWord中是否有VBA。我对MS Word及其VBA有一些了解。在MS Word中,没有任何文字未被分配任何字体样式。因此,一个更合理的问题是它是哪一个。默认字符样式是wdStyleNormal,它可以有任何字体,你可以问它是哪一个。最后,也许你应该阅读“默认段落字体” - 另一个看似没有联系的主题。 – Variatus