Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access, Word Merge, New Access Instance..bad

Status
Not open for further replies.

ChrisCalvert

Technical User
Mar 18, 2002
231
US
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
----------------------------------


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top