基本上,我有一些管理语言文件,其设置方式相同:
前三段为标题和两段。
然后,每个段落由三个部分组成,每个部分由表格分开:姓名代码对话
特征名称在中间没有任何空间(John Doe应为John Doe)。
我为这个小小小小小小小小小小小小小小小小小小小小小小小小节::
Sub RemoveSpacesFromCharacterNames()
Counter variable to track the paragraph number
Dim paragraphCounter As Integer
Loop through each paragraph in the document
For Each p In ActiveDocument.Paragraphs
Increment the counter variable
paragraphCounter = paragraphCounter + 1
Check if the paragraph is the first three paragraphs
If paragraphCounter > 3 Then
Check if the paragraph contains three parts separated by tabs
If Split(p.Range.Text, vbTab).Count = 3 Then
Dim charName As String, timeCode As String, dialogue As String
charName = Split(p.Range.Text, vbTab)(0)
timeCode = Split(p.Range.Text, vbTab)(1)
dialogue = Split(p.Range.Text, vbTab)(2)
Remove any spaces from the character name
charName = Replace(charName, " ", "")
Reconstruct the paragraph with the updated character name
p.Range.Text = charName & vbTab & timeCode & vbTab & dialogue
End If
End If
Next p
End Sub
但是它只是坠毁了MS Word, 说第9行(第Counter = 第Counter+段) (1) 溢出量,从“charName = 替换(charName,“,”)上 st
It s weird because the test document only has 5 paragraphs (3 + 2)
什么可能造成无限的休息?