H
heqian
Unregistered / Unconfirmed
GUEST, unregistred user!
i = Selection.Range.Start
j = Selection.Range.End
Selection.Find.ClearFormatting
With Selection.Find
.Text = "绝缘子"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute '查找到后SELECTION自动变为查找到的字符串!
i = Selection.Range.Start '
j = Selection.Range.End '
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="a1"
.DefaultSorting = wdSortByName
.ShowHidden = True
End With
i = Selection.Range.Start
j = Selection.Range.End
Selection.Find.ClearFormatting
With Selection.Find
.Text = "绝缘子"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
i = Selection.Range.Start
j = Selection.Range.End
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="a2"
.DefaultSorting = wdSortByName
.ShowHidden = True
End With
我改写的语句:
Procedure TFrame_xlgl_scgl_lc_neirong_new.BookMark_Create(Find_string:string;i:integer;Word_Selection:Selection);
var //查找替换WORD中的指定字符串
FindText, MatchCase, MatchWholeWord, MatchWildcards, MatchSoundsLike,MatchKashida,MatchDiacritics,
MatchAllWordForms, Forward, Wrap, Format, ReplaceWith, Replace,MatchAlefHamza,MatchControl: OleVariant;
//Range_start,Range_end:OleVariant;
bookmark_index:integer;
Selection_now:Selection;
Direction,Range_now:OleVariant;
label Next_Search;
begin
FindText := Find_string;
MatchCase := False;
MatchWholeWord := True;
MatchWildcards := False;
MatchSoundsLike := False;
MatchAllWordForms := False;
Forward := True;
Wrap := wdFindContinue;
Format := False;
ReplaceWith := '';
Replace := wdReplaceNone;
MatchKashida:= False;
MatchDiacritics:= False;
MatchAlefHamza:= False;
MatchControl:= False;
//myRange:=Range1;
//myRange.select;
Selection_now:=Word_Selection;
selection_now.Range.Start;
Selection_now.Range.End_;
Selection_now.Find.ClearFormatting;
Selection_now.Find.Execute( FindText, MatchCase, MatchWholeWord,
MatchWildcards, MatchSoundsLike, MatchAllWordForms, Forward,
Wrap, Format, ReplaceWith, Replace,MatchKashida,MatchDiacritics,
MatchAlefHamza,MatchControl);
bookmark_index:=i;
if Selection_now.Find.Found=true then
begin
//myRange:=Selection_now;
Range_now:=Selection_now.Range;
//通过选种部分颜色代码判定是否为插入部分;
if (Selection_now.Font.Color = 4278190080) or (Selection_now.Bookmarks.Count>0) then goto next_search;
WordApp.Selection.Font.Shadow;
WordApp.Selection.Font.Color:=wdColorRed;
wordApp.ActiveDocument.Bookmarks.Add('bookmark'+inttostr(bookmark_index),Range_now);
with ADOQuery_temp do
begin
sql.Clear;
sql.Add('insert into xlgq_SCGL_LC_NeiRong_bookmark');
sql.Add('(bookmark,text)');
sql.Add('valuesv_mark,:v_text)');
parameters.ParamByName('v_mark').Value:='bookmark'+inttostr(i);
parameters.ParamByName('v_text').Value:=Selection_now.Text;
execsql;
end;
bookmarkindex:=Bookmark_index+1;
next_search:
BookMark_Create(Find_string,Bookmarkindex,Selection_now);
//再次调用这个过程时,Selsection_now的值就不在改变,陷入死循环!!
//如何解决??
//如果将Selection_now.Range指定为:刚刚选种部分的尾部——文档的尾部,
//遇到查询到表格中的内容时就陷入死循环,怎么解决呀????
end;
end;
j = Selection.Range.End
Selection.Find.ClearFormatting
With Selection.Find
.Text = "绝缘子"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute '查找到后SELECTION自动变为查找到的字符串!
i = Selection.Range.Start '
j = Selection.Range.End '
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="a1"
.DefaultSorting = wdSortByName
.ShowHidden = True
End With
i = Selection.Range.Start
j = Selection.Range.End
Selection.Find.ClearFormatting
With Selection.Find
.Text = "绝缘子"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
i = Selection.Range.Start
j = Selection.Range.End
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="a2"
.DefaultSorting = wdSortByName
.ShowHidden = True
End With
我改写的语句:
Procedure TFrame_xlgl_scgl_lc_neirong_new.BookMark_Create(Find_string:string;i:integer;Word_Selection:Selection);
var //查找替换WORD中的指定字符串
FindText, MatchCase, MatchWholeWord, MatchWildcards, MatchSoundsLike,MatchKashida,MatchDiacritics,
MatchAllWordForms, Forward, Wrap, Format, ReplaceWith, Replace,MatchAlefHamza,MatchControl: OleVariant;
//Range_start,Range_end:OleVariant;
bookmark_index:integer;
Selection_now:Selection;
Direction,Range_now:OleVariant;
label Next_Search;
begin
FindText := Find_string;
MatchCase := False;
MatchWholeWord := True;
MatchWildcards := False;
MatchSoundsLike := False;
MatchAllWordForms := False;
Forward := True;
Wrap := wdFindContinue;
Format := False;
ReplaceWith := '';
Replace := wdReplaceNone;
MatchKashida:= False;
MatchDiacritics:= False;
MatchAlefHamza:= False;
MatchControl:= False;
//myRange:=Range1;
//myRange.select;
Selection_now:=Word_Selection;
selection_now.Range.Start;
Selection_now.Range.End_;
Selection_now.Find.ClearFormatting;
Selection_now.Find.Execute( FindText, MatchCase, MatchWholeWord,
MatchWildcards, MatchSoundsLike, MatchAllWordForms, Forward,
Wrap, Format, ReplaceWith, Replace,MatchKashida,MatchDiacritics,
MatchAlefHamza,MatchControl);
bookmark_index:=i;
if Selection_now.Find.Found=true then
begin
//myRange:=Selection_now;
Range_now:=Selection_now.Range;
//通过选种部分颜色代码判定是否为插入部分;
if (Selection_now.Font.Color = 4278190080) or (Selection_now.Bookmarks.Count>0) then goto next_search;
WordApp.Selection.Font.Shadow;
WordApp.Selection.Font.Color:=wdColorRed;
wordApp.ActiveDocument.Bookmarks.Add('bookmark'+inttostr(bookmark_index),Range_now);
with ADOQuery_temp do
begin
sql.Clear;
sql.Add('insert into xlgq_SCGL_LC_NeiRong_bookmark');
sql.Add('(bookmark,text)');
sql.Add('valuesv_mark,:v_text)');
parameters.ParamByName('v_mark').Value:='bookmark'+inttostr(i);
parameters.ParamByName('v_text').Value:=Selection_now.Text;
execsql;
end;
bookmarkindex:=Bookmark_index+1;
next_search:
BookMark_Create(Find_string,Bookmarkindex,Selection_now);
//再次调用这个过程时,Selsection_now的值就不在改变,陷入死循环!!
//如何解决??
//如果将Selection_now.Range指定为:刚刚选种部分的尾部——文档的尾部,
//遇到查询到表格中的内容时就陷入死循环,怎么解决呀????
end;
end;