Hi,
I want to fusion a winword template file (.dot) with a text source file
(.txt) in vb.net. My code works fine but when i have a multiline data, the \n
entries are not well-formed in my word document.
Do you have an idea ?
Thx
' ************************************************** *****
This is my code :
Dim AppWord As Word.Application
Dim doc, DocumentResultat As Word.Document
Dim format As Object = Word.WdOpenFormat.wdOpenFormatAuto
Try
AppWord = New Word.Application
AppWord.Visible = False
AppWord.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone
doc = AppWord.Documents.Open(myfiledot)
doc.Activate()
' **** Ouverture de la source de données
Dim sSource As String
sSource = "C:\publi.txt"
With doc.MailMerge
.MainDocumentType = Word.WdMailMergeMainDocType.wdFormLetters
.Destination = Word.WdMailMergeDestination.wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = False
.OpenDataSource(sSource, format, False, False, True, False,
"", "", False, "", "", _
"DSN=Text Files; DBQ=" & MyDir & ";DefaultDir=" & MyDir
& ";DriverId=27;MaxBufferSize=2048;PageTimeout=5 ;", "SELECT * FROM '" &
sSource & "'")
With .DataSource
.FirstRecord = 1
.LastRecord = -16
End With
.Execute(False)
End With
DocumentResultat = AppWord.ActiveDocument
'Fermeture du doc
doc.Close()
AppWord.Visible = True
' ************************************************** ***