Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
newschapmj1
 
Posts: n/a
Default Word 2002 - Mailmerge templates changing data source via VB

I have hundreds of Mail Merge templates which use a text file in a given
directory.
I want to open each template in vb and save it as a non mailmerge document

This should me to relocate the merge documents to a new directory.

Looking at other posts something like
ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument is needed.

However I get the 2 Dialog boxes
"xxx is a mail merge main document. Word cannot find its data source"

"Remove Data Header or Remove All Merge Information " works fine but I want
an automatic process


These pop up soon after opening the document and before AutoOpen
which I have created in my normal.dot
Sub AutoOpen()
'
' AutoOpen Macro
' Macro created 07/05/2006 by JCHAPMAN
'
ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument
MsgBox "Auto open" & vbCr
End Sub


There is a thread for Peter Jamieson 2/04/2006 but as it was only one
document the change was made manually.

Any suggests will be gratefully received.



  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP
 
Posts: n/a
Default Word 2002 - Mailmerge templates changing data source via VB

If you are getting that message, the data source must have been moved.

If you put all of the "Mail Merge templates" in a separate folder and
navigate to that folder when you run the following macro, it should do what
you want.

Dim MyPath As String
Dim MyName As String
Dim MMMainDoc As Document
'Suppress the display of alerts
Application.DisplayAlerts = wdAlertsNone
'let user select a path
With Dialogs(wdDialogCopyFile)
If .Display() -1 Then Exit Sub
MyPath = .Directory
End With

'strip quotation marks from path

If Len(MyPath) = 0 Then Exit Sub

If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If

'get files from the selected path and change the type
MyName = Dir$(MyPath & "*.*")
Do While MyName ""
Set MMMainDoc = Documents.Open(MyPath & MyName)
MMMainDoc.MailMerge.MainDocumentType = wdNotAMergeDocument
MMMainDoc.Save
MMMainDoc.Close
MyName = Dir
Loop
Application.DisplayAlerts = wdAlertsAll


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"newschapmj1" wrote in message
...
I have hundreds of Mail Merge templates which use a text file in a given
directory.
I want to open each template in vb and save it as a non mailmerge document

This should me to relocate the merge documents to a new directory.

Looking at other posts something like
ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument is needed.

However I get the 2 Dialog boxes
"xxx is a mail merge main document. Word cannot find its data source"

"Remove Data Header or Remove All Merge Information " works fine but I
want
an automatic process


These pop up soon after opening the document and before AutoOpen
which I have created in my normal.dot
Sub AutoOpen()
'
' AutoOpen Macro
' Macro created 07/05/2006 by JCHAPMAN
'
ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument
MsgBox "Auto open" & vbCr
End Sub


There is a thread for Peter Jamieson 2/04/2006 but as it was only one
document the change was made manually.

Any suggests will be gratefully received.





  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
newschapmj1
 
Posts: n/a
Default Word 2002 - Mailmerge templates changing data source via VB

Thanks

Application.DisplayAlerts = wdAlertsNone was really useful.




Reply
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
How to put graphics on envelopes? Steve Koenig Microsoft Word Help 21 April 29th 23 02:47 AM
take yet another lesson from wordperfect "reveal codes" wordperfect is superior Microsoft Word Help 5 May 11th 09 07:58 PM
hard space between words. Sandy L Microsoft Word Help 7 May 5th 06 08:25 PM
How Come? Michael Koerner Mailmerge 9 February 10th 06 10:29 PM
Specific Email Merge w/ Specific Attachements Mark B Mailmerge 9 February 21st 05 05:10 AM


All times are GMT +1. The time now is 08:48 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"