good morning

i wrote this code to write one column from adatabase to MS Word
the document opened but nothing written in it ....only new lines

Me.DsStaff1.Clear()
Me.OleDbDataAdapter1.Fill(Me.DsStaff1)
Me.applicationWord.Visible = True
Me.applicationWord.Activate()
applicationWord.Documents.Add()
Dim parra As Word.Paragraph
Dim r As Integer = 0
Dim details As String
While r < Me.DsStaff1.StaffAccount.Rows.Count
details = Me.DsStaff1.StaffAccount.Rows(r).Item("S_Name")
parra = documentWord.Paragraphs.Add()
parra.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft
applicationWord.Selection.Font.Color = Word.WdColor.wdColorBlack
applicationWord.Selection.Font.Size = 18
applicationWord.Selection.Font.Name = "Arial"
applicationWord.Selection.TypeParagraph()
documentWord.Application.Selection.TypeText(details)
r = r + 1
End While

hi....
i tryed ur code after added these 2 lines and it works
applicationWord = CreateObject("Word.Application")
documentWord = applicationWord.Documents.Add

u need to check the dataset if it has value...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.