我想找到一些text
如果这个文本在表中然后将表转换为文本,否则什么都不做
但如果没有Table
则会提供Error
Selection.Find.ClearFormatting
With Selection.Find
.Text = " - ^$^$^$^$ ^$ - ^$^$^$^$^$^$"
.Forward = True
.Wrap = wdFindStop
.Format = True
End With
Selection.Find.Execute
If Selection.Find.Found = True Then
Selection.Tables(1).Select ' This is Error position
Selection.Rows.ConvertToText Separator:=wdSeparateByTabs, NestedTables:= _
True
Else
End If
我希望do
loop
答案 0 :(得分:1)
添加条件,如果Selection.Tables.Count> 0代码
Selection.Find.ClearFormatting
With Selection.Find
.Text = " - ^$^$^$^$ ^$ - ^$^$^$^$^$^$"
.Forward = True
.Wrap = wdFindStop
.Format = True
End With
Selection.Find.Execute
If Selection.Find.Found = True Then
If Selection.Tables.Count > 0 Then
Selection.Tables(1).Select ' This is Error position
Selection.Rows.ConvertToText Separator:=wdSeparateByTabs, NestedTables:=True
End If
End If
问候。
答案 1 :(得分:0)
@nathan_sav谢谢
以下是loop
do
Selection.Find.ClearFormatting
With Selection.Find
.Text = " - ^$^$^$^$ ^$ - ^$^$^$^$^$^$"
.Forward = True
.Wrap = wdFindStop
.Format = True
End With
Selection.Find.Execute
If Selection.Find.Found = True Then
if selection.tables.count>0 then
Selection.Tables(1).Select
Selection.Rows.ConvertToText Separator:=wdSeparateByTabs, NestedTables:= _
True
else
end if
Else
exit do
End If
loop