Hi,
does anybody know how to connect directly to a SQLServer database to extract data for addresses in a word document?
i changed our database from MSAccess to a SQLServer database. The extension of the access database has tobe changed from mdb to adp.
While trying to connect directly to the access database as we did before there is no choice for adp extensions und Access driver.
If using the SQLServer driver the connection returns errors.
Beneath is the source code extract (a workaround connecing via ODBC system DSN) to connect to the SQLServer database.
If anybody can give me a hint how to setup a connection directly to SQLServer would be very helpful. Maybe i have to reference another library in VBA?
thanks
klaus
gDocAppObject.ActiveDocument.MailMerge.OpenDataSource Name:="", ConfirmConversions:= _
False, ReadOnly:=False, LinkToSource:=False, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=wdOpenFormatAuto, _
Connection:= _"DSN=HeGoSerienbrief;UID=dbo;APP=Microsoft® Query;WSID=NOTE02;DATABASE=HEGO;Network=DBMSLPCN;Trusted_Connection=Yes" _
, SQLStatement:= _
"SELECT KE_Seriendruck.Straße, KE_Seriendruck.Ort, KE_Seriendruck.Vorname, KE_Seriendruck.Nachname FROM HEGO" _
, SQLStatement1:=Chr(13) & Chr(10) & ".dbo.KE_Seriendruck KE_Seriendruck " & SerienWhere
With gDocAppObject.ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
.Destination = wdSendToNewDocument
.Execute
End With