|
网络搜到英文智能标题宏,有以下问题,请高手帮忙指点下如何修改
1)若虚词位于段首则首字母大写;
' 2)常用的搭配,例如MPa,保持格式不变;
' 3)目前仅能进行连续选中的段落格式修改,不连续选中段落无法逐一遍历并进行相应修改;例如选中了第1、3、5段,只有5段进行了遍历修改;
' 4)修改过大小写的字母用紫色标记出来;
' 5)单位不进行修改,例如kg/m3,目前修改为Kg/M3,给出示例解决办法即可
- Sub TitleCase()
- Dim lclist As String
- Dim wrd As Integer
- Dim sTest As String
- ' list of lowercase words, surrounded by spaces
- lclist = " of the by to this is from a for in into from a an and of the by to this is from a an or but and on in with under near upon at be are it"
- Selection.Range.Case = wdTitleWord
- For wrd = 2 To Selection.Range.Words.Count
- sTest = Trim(Selection.Range.Words(wrd))
- sTest = " " & LCase(sTest) & " "
- If InStr(lclist, sTest) Then
- Selection.Range.Words(wrd).Case = wdLowerCase
- End If
- Next wrd
-
- '存在问题:
- ' 1)若虚词位于段首则首字母大写;
- ' 2)常用的搭配,例如MPa,保持格式不变;
- ' 3)目前仅能进行连续选中的段落格式修改,不连续选中段落无法逐一遍历并进行相应修改;例如选中了第1、3、5段,只有5段进行了遍历修改;
- ' 4)修改过大小写的字母用紫色标记出来;
- ' 5)单位不进行修改,例如kg/m3,
- '
-
- End Sub
复制代码
|
|