ChangeFileOpenDirectory "C:\Documents and Settings\Administrator\桌面\" Documents.Open FileName:="焊缝验收单.doc", ConfirmConversions:=False, ReadOnly _ :=False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate _ :="", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="" _ , Format:=wdOpenFormatAuto, XMLTransform:="" ChangeFileOpenDirectory "C:\capp\" For I = 1 To k Selection.InsertFile FileName:=wpsno & "-A.doc", Range:="", ConfirmConversions:= _ False, Link:=False, Attachment:=False Next I Selection.HomeKey Unit:=wdStory Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "WPS号" .Replacement.Text = wpsno1 .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchByte = True .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll Selection.HomeKey Unit:=wdStory Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "上岗号" .Replacement.Text = welder .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchByte = True .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll 程序的目的:打开桌面的验收单.doc,插入需要的文件,并对刚刚插入的几个页面进行替换操作,然后重复执行。 k,wpsno1,welder,是变量,每次执行时的值可能是不同的。 现在的问题是第一遍执行完后,如何在第二次执行时将替换的范围限定在第二次插入的那些页面里。(现在的代码是每次是从开始执行)
[此贴子已经被作者于2007-1-3 18:01:44编辑过] |