ChrisCalvert
Technical User
I thought I had this figured out...sigh...
When I am running the mail merge, another instance of Access opens. I had this working on the 'test' copy on my local machine. However, I copied this out to the network share and changed the 'Drive letter path' to a UNC 'Network Path'. Now it is opening the new Access instance on the 'network' copy and it does not do this on the 'local' copy. All I am doing is calling the merge function from a button on a form. Can anyone lend some asistance on this? Here is the code for both copies:
-----------------------------------
Local:
Public Function DoStopMerge()
Dim objWord As Word.Document
Set objWord = GetObject("C:\FufilDataMerge\StopPayLetter.doc", "Word.Document"
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source
objWord.mailmerge.OpenDataSource _
Name:="C:\FufilDataMerge\Fulfilment.mdb", _
LinkToSource:=True, _
Connection:="TABLE StopLettersData", _
SQLStatement:="SELECT * FROM [StopLettersData]"
objWord.mailmerge.Destination = wdSendToNewDocument
objWord.mailmerge.Execute
'The following line must follow the Execute statement because the
'PrintBackground property is available only when a document window is
'active. Without this line of code, the function will end before Word
'can print the merged document.
objWord.Application.Options.PrintBackground = False
objWord.Application.ActiveDocument.PrintOut
objWord.Application.ActiveDocument.Close (wdDoNotSaveChanges)
objWord.Application.Quit (wdDoNotSaveChanges)
Set objWord = Nothing 'clears object instance from memory
End Function
-----------------------------------
Now, Network:
Public Function DoStopMerge()
Dim objWord As Word.Document
Set objWord = GetObject("\\AL-cpk-fps-001\homebank\DBMacroLetters\StopPayLetter.doc", "Word.Document"
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source
objWord.mailmerge.OpenDataSource _
Name:="\\AL-cpk-fps-001\homebank\DBMacroLetters\Fulfilment.mdb", _
LinkToSource:=True, _
Connection:="TABLE StopLettersData", _
SQLStatement:="SELECT * FROM [StopLettersData]"
objWord.mailmerge.Destination = wdSendToNewDocument
objWord.mailmerge.Execute
'The following line must follow the Execute statement because the
'PrintBackground property is available only when a document window is
'active. Without this line of code, the function will end before Word
'can print the merged document.
objWord.Application.Options.PrintBackground = False
objWord.Application.ActiveDocument.PrintOut
objWord.Application.ActiveDocument.Close (wdDoNotSaveChanges)
objWord.Application.Quit (wdDoNotSaveChanges)
Set objWord = Nothing 'clears object instance from memory
End Function
----------------------------------
When I am running the mail merge, another instance of Access opens. I had this working on the 'test' copy on my local machine. However, I copied this out to the network share and changed the 'Drive letter path' to a UNC 'Network Path'. Now it is opening the new Access instance on the 'network' copy and it does not do this on the 'local' copy. All I am doing is calling the merge function from a button on a form. Can anyone lend some asistance on this? Here is the code for both copies:
-----------------------------------
Local:
Public Function DoStopMerge()
Dim objWord As Word.Document
Set objWord = GetObject("C:\FufilDataMerge\StopPayLetter.doc", "Word.Document"
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source
objWord.mailmerge.OpenDataSource _
Name:="C:\FufilDataMerge\Fulfilment.mdb", _
LinkToSource:=True, _
Connection:="TABLE StopLettersData", _
SQLStatement:="SELECT * FROM [StopLettersData]"
objWord.mailmerge.Destination = wdSendToNewDocument
objWord.mailmerge.Execute
'The following line must follow the Execute statement because the
'PrintBackground property is available only when a document window is
'active. Without this line of code, the function will end before Word
'can print the merged document.
objWord.Application.Options.PrintBackground = False
objWord.Application.ActiveDocument.PrintOut
objWord.Application.ActiveDocument.Close (wdDoNotSaveChanges)
objWord.Application.Quit (wdDoNotSaveChanges)
Set objWord = Nothing 'clears object instance from memory
End Function
-----------------------------------
Now, Network:
Public Function DoStopMerge()
Dim objWord As Word.Document
Set objWord = GetObject("\\AL-cpk-fps-001\homebank\DBMacroLetters\StopPayLetter.doc", "Word.Document"
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source
objWord.mailmerge.OpenDataSource _
Name:="\\AL-cpk-fps-001\homebank\DBMacroLetters\Fulfilment.mdb", _
LinkToSource:=True, _
Connection:="TABLE StopLettersData", _
SQLStatement:="SELECT * FROM [StopLettersData]"
objWord.mailmerge.Destination = wdSendToNewDocument
objWord.mailmerge.Execute
'The following line must follow the Execute statement because the
'PrintBackground property is available only when a document window is
'active. Without this line of code, the function will end before Word
'can print the merged document.
objWord.Application.Options.PrintBackground = False
objWord.Application.ActiveDocument.PrintOut
objWord.Application.ActiveDocument.Close (wdDoNotSaveChanges)
objWord.Application.Quit (wdDoNotSaveChanges)
Set objWord = Nothing 'clears object instance from memory
End Function
----------------------------------