F
frank
The following code borrowed from 'The Access Web' works fine with
Access 2000 but I can't get it to work with Access 2003. Any ideas?
I'd also like to save the newly merged document using VBA. Any help
with the syntax is appreciated.
'************* Module Start *************
'
Option Compare Database
Option Explicit
Dim mstAppTitle As String
Function fSetAccessCaption() As Boolean
Dim dbs As Database
Const cPropNotExit = 3270
'retrieve old title
Set dbs = CurrentDb
On Error Resume Next
mstAppTitle = dbs.Properties("AppTitle")
'if property doesn't exist
If Err = cPropNotExit Then
fSetAccessCaption = False
Else
dbs.Properties("AppTitle") = "Microsoft Access"
RefreshTitleBar
fSetAccessCaption = True
End If
End Function
Sub sRestoreTitle()
CurrentDb.Properties("AppTitle") = mstAppTitle
RefreshTitleBar
End Sub
Function fMailMerge()
Dim objWord As Word.Document
Dim stMergeDoc As String
If fSetAccessCaption Then
On Error Resume Next
stMergeDoc = "mailmerge.doc"
Set objWord = GetObject(stMergeDoc, "Word.Document")
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource _
Name:=CurrentDb.Name, _
LinkToSource:=True, _
Connection:="TABLE Customer", _
SQLStatement:="Select * from [Customer]"
objWord.MailMerge.Execute
objWord.Close
'restore the caption
Call sRestoreTitle
End If
End Function
'************* Module End *************
Access 2000 but I can't get it to work with Access 2003. Any ideas?
I'd also like to save the newly merged document using VBA. Any help
with the syntax is appreciated.
'************* Module Start *************
'
Option Compare Database
Option Explicit
Dim mstAppTitle As String
Function fSetAccessCaption() As Boolean
Dim dbs As Database
Const cPropNotExit = 3270
'retrieve old title
Set dbs = CurrentDb
On Error Resume Next
mstAppTitle = dbs.Properties("AppTitle")
'if property doesn't exist
If Err = cPropNotExit Then
fSetAccessCaption = False
Else
dbs.Properties("AppTitle") = "Microsoft Access"
RefreshTitleBar
fSetAccessCaption = True
End If
End Function
Sub sRestoreTitle()
CurrentDb.Properties("AppTitle") = mstAppTitle
RefreshTitleBar
End Sub
Function fMailMerge()
Dim objWord As Word.Document
Dim stMergeDoc As String
If fSetAccessCaption Then
On Error Resume Next
stMergeDoc = "mailmerge.doc"
Set objWord = GetObject(stMergeDoc, "Word.Document")
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource _
Name:=CurrentDb.Name, _
LinkToSource:=True, _
Connection:="TABLE Customer", _
SQLStatement:="Select * from [Customer]"
objWord.MailMerge.Execute
objWord.Close
'restore the caption
Call sRestoreTitle
End If
End Function
'************* Module End *************