在Excel中find并replaceembedded式word文档后,将变化保存在embedded式word文档中

我正在构build一个将使用模板(Excel中embedded的Word文档)的代码,并使用来自Excel的input来查找和replace模板中的某些单词。 我已经成功编写了模板的开放代码,在模板中查找并replace。

但是之后,当我在Excel中检查embedded的Word文档时,被replace的单词被保存。 我不想重写模板的内容,但每次运行代码时,都会自动保存在查找和replace过程中所做的更改。 我只是希望它find并replace,然后将副本保存到我的本地文件夹。

我正在使用后期绑定,因为我们团队使用的Excel版本存在限制。

我不知道下面的代码的function是否导致更改被保存在embedded式Word文档中。

.Execute Replace:=2 'wdReplaceAll 

这是我的完整代码:

 Sub Button1_Click() Application.ScreenUpdating = False Set WDApp = CreateObject("Word.Application") WDApp.Visible = True Set WDDoc = Sheets("Sheet1").OLEObjects("Template_112225") WDDoc.Verb Verb:=xlOpen WDApp.Selection.WholeStory Call SplitCell Call Find("<Part Num>", Sheets("Sheet2").Cells(8, 4).Value) Call Find("<Dataset>", Sheets("Sheet2").Cells(7, 3).Value) Call Find("<Letter>", Sheets("Sheet2").Cells(8, 5).Value) Set WDDoc = Nothing Set WDApp = Nothing Set Rng = Nothing End Sub Sub Find(Find_Value As String, New_Value As String) With WDApp.Selection.Find .Text = Find_Value .Replacement.Text = New_Value .Forward = True .Wrap = 1 'wdFindContinue .Execute Replace:=2 'wdReplaceAll End With End Sub Sub SplitCell() Dim txt As String Dim i As Integer Dim NumberLetter As Variant txt = Sheets("Sheet2").Cells(8, 3).Value NumberLetter = Split(txt, "/") For i = 0 To UBound(NumberLetter) Cells(8, i + 4).Value = NumberLetter(i) Next i End Sub 

也有可能有一个代码,将使另存为对话框出现? 所以用户可以select保存修改的副本的位置。