如何使用VBA在MS Word中的标签基础上获取单独的字符串?
我有下面的字符串,我想在word的基础上拆分它 字符串:如何使用VBA在MS Word中的标签基础上获取单独的字符串?,vba,Vba,我有下面的字符串,我想在word的基础上拆分它 字符串: Your meaning <b>is unclear here</b>: please revise. 请推荐。南麂!虽然so不是一个代码编写服务等等,但我喜欢你的问题。以下是您可以使用的内容: Option Explicit Sub Remove() Dim str_note As String Dim str_arr() As String Dim str_arr2()
Your meaning <b>is unclear here</b>: please revise.
请推荐。南麂!虽然so不是一个代码编写服务等等,但我喜欢你的问题。以下是您可以使用的内容:
Option Explicit
Sub Remove()
Dim str_note As String
Dim str_arr() As String
Dim str_arr2() As String
Dim l_counter As Long
Dim l_counter2 As Long
str_note = "Your meaning <b>is unclear here</b>: please revise."
str_note = Replace(str_note, ">", "<")
Debug.Print str_note
str_arr = Split(str_note, "<")
For l_counter = 0 To UBound(str_arr)
If l_counter Mod 2 = 0 Then
If l_counter <> 0 Then l_counter2 = l_counter2 + 1
ReDim Preserve str_arr2(l_counter2)
str_arr2(l_counter2) = str_arr(l_counter)
End If
Next l_counter
End Sub
选项显式
子删除()
作为字符串的Dim str_音符
Dim str_arr()作为字符串
Dim str_arr2()作为字符串
调暗l_计数器的长度
调暗l_计数器2的长度
str_note=“此处您的意思不清楚:请修改。”
str_note=Replace(str_note,“>”,“您是否尝试过Split
函数?为什么它不起作用?您尝试了什么来修复它?@arcadeprecinct Split函数基于delimiter.Ex.“\”,“,“等等。我想在标记的基础上进行分隔。Split
也使用多个字符作为分隔符。如果您对此感到不舒服,请先用一些单字符分隔符替换标记。@Arcadeprecint谢谢谢谢你。但有时我有两个标签。例如你在这里的意思不清楚:请修改联系我们以获得更多帮助。我希望这在同样的情况下也能起作用。@NanjiMange,如果对你有帮助,请随意选择答案作为你问题的答案(绿色复选框):)是的!谢谢:)@offtopic——奇怪的是,第一篇文章中的“嗨,南吉!”仅仅是“南吉!”就变成了这样。我觉得这样有点粗鲁:)没关系。什么是离题?可以在StackOverflow上这样聊天吗!:D
Option Explicit
Sub Remove()
Dim str_note As String
Dim str_arr() As String
Dim str_arr2() As String
Dim l_counter As Long
Dim l_counter2 As Long
str_note = "Your meaning <b>is unclear here</b>: please revise."
str_note = Replace(str_note, ">", "<")
Debug.Print str_note
str_arr = Split(str_note, "<")
For l_counter = 0 To UBound(str_arr)
If l_counter Mod 2 = 0 Then
If l_counter <> 0 Then l_counter2 = l_counter2 + 1
ReDim Preserve str_arr2(l_counter2)
str_arr2(l_counter2) = str_arr(l_counter)
End If
Next l_counter
End Sub