I have been trying to get a mail merge working for ages made this up from various sites, im gettin the error after the ODBC connecter page comes up and i click okay
the error is "cannot open datasource" any immediate ideas ? thanks
im using mysql if that helps?
the error is "cannot open datasource" any immediate ideas ? thanks
VB.NET:
Public Sub domailmerge()
Dim oApp As Word.Application
Dim oDoc As Word.Document
'Start a new document in Word.
oApp = New Word.Application
'Make Word visible (to see the dialog box).
oApp.Visible = True
oDoc = oApp.Documents.Add
With oDoc.MailMerge
.MainDocumentType = Word.WdMailMergeMainDocType.wdFormLetters
'Set up the data source for the mail merge.
Dim sSQL As String
Dim sConn As String
sSQL = "Select FirstName, LastName from tblmember"
sConn = "C:\Documents and Settings\halo9\Desktop\supervid tblmember.odc"
.OpenDataSource(Name:=sConn, SQLStatement:=sSQL)
'Set up the document with the fields.
.EditMainDocument()
.Fields.Add(Range:=oApp.Selection.Range, Name:="FirstName")
oApp.Selection.TypeParagraph()
.Fields.Add(Range:=oApp.Selection.Range, Name:="LastName")
oApp.Selection.TypeParagraph()
'Execute the merge.
.Destination = Word.WdMailMergeDestination.wdSendToNewDocument
.Execute()
End With
'Clean up.
oDoc = Nothing
oApp = Nothing
End Sub
im using mysql if that helps?
Last edited: