> I need to reverse the process of mail merge. I've created
> a mail merge template, removed the datasource and created
[quoted text clipped - 11 lines]
>
> Is there a way to improve the performance?
Sorry about that Cindy. I'm using word 2000. I don't know
what else you need. I think that Word needs to check if
the excel document is open and link to it, not open
another copy of Excel.
You helped me last month also and I appreciate it.
Dave Baxandall
dave.baxandall@telus.com
Thanks
>-----Original Message-----
>Hi Dave,
[quoted text clipped - 35 lines]
>
>.
Cindy since we are 1/2 a world away I'm going to include
my code
In word: I just change SUB start_it to run in word or excel
Global SaveDocName As Variant
Global FileNamE As String
'Sub start_it()
Sub start_it(Source As String)
FileNamE = Source
'FileNamE = "C:\My Documents\HR Compensation
DisplayOnly 2004 ver1.xls"
Do_The_Merge
End Sub
Sub Do_The_Merge()
Dim SQLstring As String
SQLstring = "SELECT * FROM " & FileNamE & " WHERE ((print
= 'X'))" & ""
Debug.Print SQLstring
ActiveDocument.MailMerge.MainDocumentType =
wdFormLetters
SendKeys "{enter}", True
ActiveDocument.MailMerge.OpenDataSource
Name:=FileNamE, _
ConfirmConversions:=False, ReadOnly:=False,
LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", _
WritePasswordDocument:="",
WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:="print_it",
SQLStatement:="", _
SQLStatement1:=""
ActiveDocument.MailMerge.DataSource.QueryString =
SQLstring
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute
'Pause:=True
End With
End Sub
The code above works when I run it in word
*******************
My Excel code is:
Sub start_word1()
Dim mWordApp As Word.Application
Const docName As String = "C:\My Documents\HRCOMP1.doc"
Dim Merge_XLs As Variant
On Error GoTo EndIt
Merge_XLs = ActiveWorkbook.FullName
Set mWordApp = New Word.Application
' open the word document
With mWordApp
.Documents.Open FileName:=docName, ReadOnly:=True
.Visible = True
.Run macroname:="start_it", varg1:=Merge_XLs
End With
EndIt:
Debug.Print Err.Number; Err.Description
Set mWordApp = Nothing
End Sub
Thanks again.
>-----Original Message-----
>Sorry about that Cindy. I'm using word 2000. I don't know
[quoted text clipped - 57 lines]
>>
>.
Cindy M -WordMVP- - 28 Nov 2003 16:20 GMT
> I'm using word 2000. I think that Word needs to check if
> the excel document is open and link to it, not open
> another copy of Excel.
Well, Word simply doesn't do this. It's a problem with how
the (VERY OLD) DDE technology functions.
What you should try is activating the "Select method"
checkbox in the "Open Data Source" dialog box. Once you've
chosen the Excel workbook, you should get a list with
(probably) 3 entries. Choose ODBC.
If you don't see the data range you want listed, click
"Options" and activate all the checkboxes you'll get. Now
you should be able to choose the data.
Record this in a macro in order to get the syntax you need
for your code.
Cindy Meister

Signature
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Sep 30 2003)
http://www.mvps.org/word
This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:-)