Macro
Macro
Macro
Option Explicit
Sub LinkToSourceFile()
Dim strBook As String
Dim strBookName As String
Dim strDataSource As String
strBookName = "\dbpokja.xlsm"
strBook = ActiveDocument.Path & strBookName
strDataSource = ActiveDocument.MailMerge.DataSource.Name
ActiveDocument.MailMerge.OpenDataSource Name:= _
strBook, _
ConfirmConversions:=False, _
ReadOnly:=False, _
LinkToSource:=True, _
AddToRecentFiles:=False, _
PasswordDocument:="", _
PasswordTemplate:="", _
WritePasswordDocument:="", _
WritePasswordTemplate:="", _
Revert:=False, _
Format:=wdOpenFormatAuto, _
Connection:= _
"Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=strBook;Mode=Read;E
xtended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:
Registry Path="""";Jet OLEDB:Engine Type=37;Jet OLEDB:D", _
SQLStatement:="SELECT * FROM `baku$`", _
SQLStatement1:="", SubType:= _
wdMergeSubTypeAccess
End Sub
Sub AutoClose()
If Application.Version < 10 Then
ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument
End If
ActiveDocument.Save
End Sub
Sub AutoOpen()
LinkToSourceFile
ActiveDocument.MailMerge.ViewMailMergeFieldCodes = wdToggle
End Sub