473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Fusion with winword and vb.net

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
' ************************************************** ***
May 7 '07 #1
0 935

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Just D. | last post by:
Guys, I'm writing the Windows Application and one of the ideas is to use a RichText field to store/show some formatted text, probably with pictures. The problem is that this RichEdit control is...
2
by: CSDunn | last post by:
Hello, My boss is considering the purchase of a calendar/scheduler program for our school district, and part of the setup calls for the installation of Macromedia's Cold Fusion software. My bosses...
2
by: Robin Tucker | last post by:
Hi, I am diligently releasing (Marshal.ReleaseComObject (o) ) all references I pick up while generating a report using VB.NET in my software. At least, I *think* I am. However, when I have...
3
by: Dean Slindee | last post by:
The code below is being used to launch WinWord.exe from a VB.NET program. Word launches, but displays this error message: "Word has experienced an error trying to open the file. Try these...
2
by: Dean Slindee | last post by:
The code below is being used to launch WinWord.exe from a VB.NET program. Word launches, but displays this error message: "Word has experienced an error trying to open the file. Try these...
4
by: tomlebold | last post by:
I'm a Microsoft Access and ASP.NET developer. Currently I'm working at a company that uses Cold Fusion and we can't find any developers. I suggested that we use ASP.NET and Visual Studios. The...
1
by: tvjraman | last post by:
Visual Basic 6 I use Getobject() to get the object of Word application. I always get the first instance of Winword.exe I have a macro in another instance of Winword.exe I need to get the...
2
by: Dean Slindee | last post by:
Using this statement to utilize the spell checker in WinWord: WinOffice.clsWord.SpellChecker(txtNote.Text) 'this does not work because no main window is displayed 'Dim proc =...
2
ajester
by: ajester | last post by:
I need WinWord to look like it's being executed from the correct path: C:\Program Files\Microsoft Office\Office12\WinWord.exe when in reality it's being launch from a Java app using the path...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.