Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / November 2003

Tip: Looking for answers? Try searching our database.

Starting Mailmerge from Excel - slow

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave Baxandall - 26 Nov 2003 16:26 GMT
I need to reverse the process of mail merge. I've created
a mail merge template, removed the datasource and created
a macro that is expecting the datasource path in it.

In word I can have the excel datasource open and run the
macro from inside word everything works fine.
but
In Excel I:
1. Create a word.application and call the mail merge
template
2. The spreadsheet is re-opened and I need to click read-
only.
3. But this takes up to 60 seconds to run.

Is there a way to improve the performance?

Thank you
Dave Baxandall
Cindy M  -WordMVP- - 27 Nov 2003 12:13 GMT
Hi Dave,

Since you don't mention which version of Word this is, we
can only guess. From the sound of it, the merge document was
set up in Word 2000 or earlier, and uses DDE to connect to
the data source. And this is what's causing the delay.

I'd try setting up the link to the data source using ODBC.
And to tell you how to do that, we DO need to know which
version of Word you have at hand.

> 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?

Cindy Meister
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
:-)
- 27 Nov 2003 15:02 GMT
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]
>
>.
- 27 Nov 2003 16:40 GMT
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

:-)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.