因为乱码,所以把问题重写一遍,谢谢
比如WORD模板文档可能如下:
«Date»
«MailingAddr»
Reference No : «Appln_Ref_No»Dear Customer,Thank you for applying for our Personal Line of Credit. To ensure speedy processing of your application, please。。现在需要在VB程序中对上面的一些参数进行替换,如«Date»替换为2001-09-24,等等。
问:如何进行?
(如果没错的话,应该是用什么mail merge的东东,请高手赐我代码吧,或点拨几下吧,谢谢〕
来几行抛砖引玉的代码:Dim wrdApp As Object 'Word.Application
Dim wrdDoc As Object 'Word.Document
Set wrdApp = CreateObject("word.application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.documents.open(customertemplateFile, ReadOnly:=True)
......
'这里进行替换操作
......
wrdDoc.printpreview
......
比如WORD模板文档可能如下:
«Date»
«MailingAddr»
Reference No : «Appln_Ref_No»Dear Customer,Thank you for applying for our Personal Line of Credit. To ensure speedy processing of your application, please。。现在需要在VB程序中对上面的一些参数进行替换,如«Date»替换为2001-09-24,等等。
问:如何进行?
(如果没错的话,应该是用什么mail merge的东东,请高手赐我代码吧,或点拨几下吧,谢谢〕
来几行抛砖引玉的代码:Dim wrdApp As Object 'Word.Application
Dim wrdDoc As Object 'Word.Document
Set wrdApp = CreateObject("word.application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.documents.open(customertemplateFile, ReadOnly:=True)
......
'这里进行替换操作
......
wrdDoc.printpreview
......
解决方案 »
- 有自编网络传输工具的么?
- 多个表之间联系的问题,可能涉及到全局变量。新手求解!谢谢了,大家都来看看!
- VB+ADO连接MySQL数据库,为何不能产生FetchProgress和FetchComplete事件.
- ASP网页里嵌套javascript文件网页有错,怎么回事呢?
- 在模块中定义的对象变量应在何处释放呢?(指在*.bas文件中定义的变量)
- 文件列表框没有内容
- 哪个可以教我学好VB?
- Datagrid中如何实现单元格内容自动换行?谢谢大家
- 急!关于visual studio 6.0 安装的问题
- 在使用textbox时如何判定行数已超过显示范围并将滚动条显示出来?
- 访问另一个FORM的函数
- 高手请看:E-BOOK的翻书效果用VB如何实现
比如WORD模板文档可能如下:
<<Date>>
<<MailingAddr>>
Reference No : <<Appln_Ref_No>>Dear Customer,Thank you for applying for our Personal Line of Credit. To ensure speedy processing of your application, please。。现在需要在VB程序中对上面的一些参数进行替换,如<<Date>>替换为2001-09-24,等等。
问:如何进行?
(如果没错的话,应该是用什么mail merge的东东,请高手赐我代码吧,或点拨几下吧,谢谢〕
来几行抛砖引玉的代码:Dim wrdApp As Object 'Word.Application
Dim wrdDoc As Object 'Word.Document
Set wrdApp = CreateObject("word.application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.documents.open(customertemplateFile, ReadOnly:=True)
......
'这里进行替换操作
......
wrdDoc.printpreview
......
'KN;01JUN2000
Dim wrdSelection As Object
Dim wrdMailMerge As Object
Dim wrdMergeFields As Object
' Dim wrdSelection As Word.Selection
' Dim wrdMailMerge As Word.MailMerge
' Dim wrdMergeFields As Word.MailMergeFields
Dim StrToAdd As String
Dim bResult As Boolean
Dim sOutPut As String
bResult = False
On Error GoTo ErrHandler
' Create an instance of Word and make it visible
sOutPut = LTrim(sOutPutLetterPath) + Trim(sOutPutLetterName)
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.documents.Open(sLetterTemp, ReadOnly:=True)
Set wrdMailMerge = wrdDoc.MailMerge
'get datasource
If GetMailMergeDataSoruce Then
wrdMailMerge.Destination = wdSendToNewDocument
With wrdMailMerge.DataSource
.FirstRecord = 1
.LastRecord = 1
End With wrdMailMerge.Execute False
wrdApp.ActiveDocument.Saved = True
If Dir(sOutPutLetterPath, vbDirectory) <> "" Then
wrdApp.ActiveDocument.SaveAs sOutPut
End If
wrdApp.ActiveDocument.PrintOut
wrdApp.ActiveDocument.Close False
If Dir(sOutPut, vbDirectory) <> "" Then
If Not gobjOnLineManager.MTXUpdLetterRequest(sOutPutLetterName, m_Appln_Ref_No) Then GoTo ExitHere
' If Not gobjLetterGenManager.MTXUpdLetterRequest(sOutPutLetterName, m_Appln_Ref_No) Then GoTo ExitHere
End If
'MsgBox "Mail Merge Complete.", vbMsgBoxSetForeground
bResult = True
End If
ExitHere:
CreatePrintQueueLetter = bResult
If Not wrdApp Is Nothing Then
If Not wrdDoc Is Nothing Then
wrdDoc.MailMerge.MainDocumentType = wdNotAMergeDocument
wrdDoc.Close False
End If
wrdApp.Quit
End If
' Release References
Set wrdSelection = Nothing
Set wrdMailMerge = Nothing
Set wrdMergeFields = Nothing
Set wrdDoc = Nothing
Set wrdApp = Nothing
If Dir(gDataSrc, vbDirectory) <> "" Then Kill gDataSrc
Exit Function
ErrHandler:
write_textlog "< " & Me.ClassName & ".CreatePrintQueueLetter>" & Err.Number & _
Err.Description
GoTo ExitHere
End Function