我有一个单词(2010)dokument,数据看起来像这样:
----------------------------------------------------------------------------
15-aug-2017 15:28 Start Template Page 2
-----------------------------------------------------------------------------
(mm) ACTUAL NOMINAL LO-TOL HI-TOL DEVIATION GRAPHIC ERROR
-------------------------------------------------------------------------------
Circle:Ø15_H13_2
X-axis(PCS)-74.815 74.940 -0.125
Y-axis(PCS) 74.975 74.940 0.035
Diameter 15.420 15.000 +0.000 +0.270 0.420 -*-+-->
0.150
TruePos2D 0.260 1.770(M=0.27) <--*---
----------------------------------------------------------------------
我正在尝试做的事情:
X-axis(PCS) 74.815 74.940 -0.125
介于74.940和-125之间,有超过22个空格所以我想要3个标签,介于74.815和74.940之间它更多12个空格所以我想要2个标签和介于(PCS)和74.815之间它超过2个空格所以我只想要1个标签X-axis(PCS)-
所以我最终想要的是:
Circle:Ø15_H13_2
X-axis(PCS) ^t -74.815 ^t ^t 74.940 ^t ^t ^t -0.125
Y-axis(PCS) ^t 74.975 ^t ^t 74.940 ^t ^t ^t 0.035
Diameter ^t 15.420 ^t 15.000 ^t 0.000 ^t 0.270 ^t 0.420 ^t 0.150
`TruePos2D ^ t 0.260 ^ t ^ t ^ t 1.770(M = 0.27)
当wildcard = true时我得到的错误消息:运行时错误5560,查找什么文本包含无效的模式匹配表达式
当wildcard = false时,我没有收到错误消息,但它只删除了带有模板的文本以及文本页面
所以我beleve wildcard = true并且我遇到.Text = "[ ]{22,}"
请帮帮我!这是我第一次编程
Sub CleanUpPastedText()
Application.ScreenUpdating = False
With Selection.Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
.Text = "[ ]{22,}"
.Replacement.Text = "^t^t^t"
.Execute Replace:=wdReplaceAll
.Text = "[ ]{12,}"
.Replacement.Text = "^t^t"
.Execute Replace:=wdReplaceAll
.Text = "[ ]{2,}"
.Replacement.Text = "^t"
.Execute Replace:=wdReplaceAll
.Text = "[-]{2,}"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
.Text = "[ ]{1,}"
.Replacement.Text = "^t"
.Execute Replace:=wdReplaceAll
.Text = " Start Template"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
.Text = "Page "
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
.Text = "\(mm\) ACTUAL NOMINAL LO-TOL HI-TOL DEVIATION GRAPHIC ERROR"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
.Text = "X-axis\(PCS\-)"
.Replacement.Text = "X-axis\(PCS\)^t- "
.Execute Replace:=wdReplaceAll
.Text = "[\*]"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
.Text = "[+]"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
.Text = "[<]"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
.Text = "[>]"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub