问题描述
我有一个清理宏,可以帮助我使文档保持一致。它包括"是/否"。按钮,所以我可以做出选择,因为不是每个选择都需要清理。现在我希望有一个序列来搜索CO2(所有大写字母)并使
" 2"下标(以及后来将另一个将ft2中的"2"变为上标的序列)。对于我的生活,我无法弄清楚如何编写选择最后一个字符的代码并将其更改为上标/下标而不改变整行的
。
这是我已经拥有的代码块:
Dim oRngCO2 As Word.Range
设置oRngCO2 = ActiveDocument.Range
使用oRngCO2.Find
.Text =" CO2"
.MatchWildcards = True
.Wrap = wdFindStop
当.Execute
oRngCO2.Select
跨度>选择案例MSGBOX(QUOT;下标QUOT ;, vbYesNoCancel," FOUND" + oRngCO2)
oRngCO2.Characters.Last = CHR(160)
          案例vbCancel
退出子
Case Else:'没有任何东西
结束选择
oRngCO2.Collapse wdCollapseEnd
Wend
结束
请告诉我需要进行哪些调整,以便"2"在这个例子中是下标,在其他情况下是上标。谢谢。
I have a cleanup macro that helps me make documents consistent. It includes "yes/no" buttons so I can make a choice since not every selection needs to be cleaned up. Now I want to have a sequence where it searches for CO2 (all caps) and make the "2" subscript (and, later, another sequence that changes the "2" in ft2 into superscript). For the life of me, I can't figure out how to write the code that select that last character and change it to superscript/subscript without changing the whole line.
Here's the block of code I already have:
Dim oRngCO2 As Word.Range
Set oRngCO2 = ActiveDocument.Range
With oRngCO2.Find
.Text = "CO2"
.MatchWildcards = True
.Wrap = wdFindStop
While .Execute
oRngCO2.Select
Select Case MsgBox("Subscript?", vbYesNoCancel, "FOUND " + oRngCO2)
Case vbYes
oRngCO2.Characters.Last = Chr(160)
Case vbCancel
Exit Sub
Case Else: 'No nothing
End Select
oRngCO2.Collapse wdCollapseEnd
Wend
End With
Please show me what tweaks I need to make so that the "2" is subscript in this instance and superscript in others. Thanks.
这篇关于宏添加Superscipt /下标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!