给你一小段代码吧 Dim objword As New Word.Global Dim wordApp As New Word.Application Dim mydoc As Word.Document wordApp.Visible = False Set mydoc = wordApp.Documents.Open(FileName:=App.Path & "\PZDY1.doc") With wordApp.Selection.Find .ClearFormatting .Replacement.ClearFormatting .Text = "*币种*" .Replacement.Text = "人民币" .Execute Replace:=wdReplaceAll END WITH……
可以编写三个函数,第一个打开模板,第二个插入数据,第三个关闭和保存文档 Private objword As New Word.Global Private oWord As New Word.Application Private mydoc As New Word.Document Set mydoc = oWord.Documents.Add(strDotPathAndName, , wdFormatDocument, True)
Dim wordApp As New Word.Application
Dim mydoc As Word.Document
wordApp.Visible = False
Set mydoc = wordApp.Documents.Open(FileName:=App.Path & "\PZDY1.doc")
With wordApp.Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "*币种*"
.Replacement.Text = "人民币"
.Execute Replace:=wdReplaceAll
END WITH……
Private objword As New Word.Global
Private oWord As New Word.Application
Private mydoc As New Word.Document
Set mydoc = oWord.Documents.Add(strDotPathAndName, , wdFormatDocument, True)