D
darren via AccessMonster.com
Hi
I am building my first split database for users with multiple FEs and its
just occurer to me that this will leave me facing the prospect of setting up
not only each users front end but also a set of merge documents for them. I
am therefore looking to give them a fe with a set of merge docs and
programmativally set their datasources....... but it's not going so well...
(note also that the front end may be password protected.)
Public Function fnMergeIt()
On Error GoTo Err_fnMergeIt
Dim db As Database
Dim objWord As Word.Document
Dim doc As String
Dim dbPath As String
Dim strConnection As String
dbPath = CurrentProject.FullName
doc = CurrentProject.path & "\TestSL.doc"
strConnection = "DSN=MS Access Database;DBQ=" & dbPath & ";FIL=MS
Access;PWD=Password;UID=admin;"
Set objWord = GetObject(doc, "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the calling database.
objWord.MailMerge.OpenDataSource _
Name:=dbPath, _
ReadOnly:=True, _
LinkToSource:=True, _
Connection:=strConnection, _
SQLStatement:="SELECT * FROM [tmptblSL]"
' Execute the mail merge.
objWord.MailMerge.Execute
Exit_fnMergeIt:
Set objWord = Nothing
Exit Function
Err_fnMergeIt:
If Err.Number = 247 Then
MsgBox " The merge document is already open."
Else
MsgBox "fnMergeIt: " & Err.Number & " - " & Err.Description
End If
Resume Exit_fnMergeIt
End Function
When run this open the word doc but I get a dialog bow 'data link properties'
pop up (which I don't want). When I click ok to the execute command then
comes into effect and opens up another non-merged version of the letter as
well???
If I disable the execute command then I think I'm left with the original with
the correct datasource.
How can I stop the data link properties box appearing and am I missing
anything from my logic?
Thanks
Help! (please)
I am building my first split database for users with multiple FEs and its
just occurer to me that this will leave me facing the prospect of setting up
not only each users front end but also a set of merge documents for them. I
am therefore looking to give them a fe with a set of merge docs and
programmativally set their datasources....... but it's not going so well...
(note also that the front end may be password protected.)
Public Function fnMergeIt()
On Error GoTo Err_fnMergeIt
Dim db As Database
Dim objWord As Word.Document
Dim doc As String
Dim dbPath As String
Dim strConnection As String
dbPath = CurrentProject.FullName
doc = CurrentProject.path & "\TestSL.doc"
strConnection = "DSN=MS Access Database;DBQ=" & dbPath & ";FIL=MS
Access;PWD=Password;UID=admin;"
Set objWord = GetObject(doc, "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the calling database.
objWord.MailMerge.OpenDataSource _
Name:=dbPath, _
ReadOnly:=True, _
LinkToSource:=True, _
Connection:=strConnection, _
SQLStatement:="SELECT * FROM [tmptblSL]"
' Execute the mail merge.
objWord.MailMerge.Execute
Exit_fnMergeIt:
Set objWord = Nothing
Exit Function
Err_fnMergeIt:
If Err.Number = 247 Then
MsgBox " The merge document is already open."
Else
MsgBox "fnMergeIt: " & Err.Number & " - " & Err.Description
End If
Resume Exit_fnMergeIt
End Function
When run this open the word doc but I get a dialog bow 'data link properties'
pop up (which I don't want). When I click ok to the execute command then
comes into effect and opens up another non-merged version of the letter as
well???
If I disable the execute command then I think I'm left with the original with
the correct datasource.
How can I stop the data link properties box appearing and am I missing
anything from my logic?
Thanks
Help! (please)