Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
ucmlamb ucmlamb is offline
Junior Member
 
Posts: 2
Default Mailmerge doc will not open from Access 2003

I am using Access 2003 to open a Mail Merge document using the following VB code. The document uses a text file as the datasource. This worked in Access 2000, but the document will not open in Access 2003, word opens and the status bar displays "docname.doc: 1,222 characters..." then the document never opens. If I remove the "WordDoc.Close (False)" line the document will display, but not with the updated merge data from the datasource, instead it opens with the saved data from the "template" or original merge document. As I said this code works perfectly in earlier versions of Access.

Function MergeWord(strDocName As String)
Dim WordApp As Object ' running instance of word
Dim WordDoc As Object ' one instance of a word doc
Dim strActiveDoc As String ' doc name (no path)
Dim lngWordDest As Long ' const for dest, 0 = new doc, 1 = printer

On Error GoTo CreateWordApp
Set WordApp = GetObject(, "Word.Application")
On Error Resume Next

Set WordDoc = WordApp.Documents.Open(strDocName)

strActiveDoc = WordApp.ActiveDocument.Name

With WordDoc.MailMerge
.Destination = 0 ' 0 = new doc
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = 1
.LastRecord = 1
End With
.Execute Pause:=True
End With
WordDoc.Close (False)

WordApp.Visible = True
WordApp.Windows(WordApp.Windows.Count).Activate

AppActivate "Microsoft Word"
WordApp.WindowState = 0 'wdWindowStateRestore

Set WordApp = Nothing
Set WordDoc = Nothing

DoEvents
Exit Function

CreateWordApp:
...
End Function


Any help would be appreciated.
Thanks
ucmlamb
 
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word applies direct format on File open Uriel Microsoft Word Help 16 November 27th 05 07:22 PM
Word 2003 slow to open Word 2003 Virus Scanning STOP Microsoft Word Help 0 August 15th 05 12:38 AM
Access to Word link 2003 Jack Mailmerge 4 August 8th 05 05:43 PM
How to use access query computed fields in Word mailmerge Rey Mailmerge 5 June 23rd 05 06:26 PM
Word 2003 Hangs when I try to Open a Doc -=Tarik=- Microsoft Word Help 1 May 19th 05 05:58 AM


All times are GMT +1. The time now is 02:54 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"