Google Answers Logo
View Question
 
Q: Merging Word files using VBA - "Word cannot find data source" error ( No Answer,   0 Comments )
Question  
Subject: Merging Word files using VBA - "Word cannot find data source" error
Category: Computers > Programming
Asked by: rozziew-ga
List Price: $25.00
Posted: 25 Mar 2003 00:13 PST
Expires: 25 Mar 2003 18:34 PST
Question ID: 180600
Merging Word files using VBA - I am using a DDE channel to merge word
files and every now and again I get the "Word cannot find data source"
error.   The data source is there - and if I manually exit and run the
procedure again, it will work fine.   I have trapped this error (286)
but I have been unable to find a way to close the document so I can
try again.  Can anyone tell me the word basic command I need to send
to word via the DDE channel to close the message box so I can get my
program to start again.   These ones do not work since the message box
is waiting for a response

DDEExecute ch, "[FileClose 2]"
DDEExecute ch, "[AppClose]"

Hope someone there can help me!

Request for Question Clarification by hammer-ga on 25 Mar 2003 05:49 PST
What version of Word are you using?
Could you post your code?

- Hammer

Clarification of Question by rozziew-ga on 25 Mar 2003 18:11 PST
This is the code I am using:

ch = StartApp(winwordpath, "WINWORD", "SYSTEM")
            
            On Error GoTo ErrorhandlerGen '
            DDEExecute ch, "[FileOpen .Name = """ & mfn & """,
.ReadOnly = 1]"
          
            DDEExecute ch, "[MailMergeMainDocumentType 0]"
            DDEExecute ch, "[MailMergeOpenDataSource .Name = """ & dfn
& """, .ConfirmConversions = 0, .ReadOnly = 0]"
           
            RESP = SysCmd(4, "Merging " & mfn)
          on error GoTo Errtimeout
            On Error GoTo errPrintLetterMerge
'**********************************************************
            
            ' RCC 25 Mar 2003 - added this to trap a specific error
which occurs when word
            ' thinks it can't find the mail merge data file, which
will allow the program to keep
            ' running without human intervention, and without losing
the file.
                        
            DDEExecute ch, "[MailMerge .CheckErrors = 1, .Destination
= 0, .MergeRecords = 0, .Suppression = 0, .MailMerge,
.MailAsAttachment = 0]"

Clarification of Question by rozziew-ga on 25 Mar 2003 18:14 PST
Sorry disregard that last one - I hit the wrong button when I was
still editing it

This is part of the code I am using - it hickups on the FILEOPEN line
if Word cannot find the data source.   I know I can remove the header
information from the word files but then it makes it hard to edit
them.   Well not for me but I have to hand all this over in July.
 
ch = StartApp(winwordpath, "WINWORD", "SYSTEM") 
             
On Error GoTo ErrorhandlerGen  
DDEExecute ch, "[FileOpen .Name = """ & mfn & """, .ReadOnly =
1]"DDEExecute ch, "[MailMergeMainDocumentType 0]"
DDEExecute ch, "[MailMergeOpenDataSource .Name = """ & dfn & """,
.ConfirmConversions = 0, .ReadOnly = 0]"

Clarification of Question by rozziew-ga on 25 Mar 2003 18:16 PST
Sorry forgot the version - the prod environment is word97.   I've
tried it with word 2000 as well - same thing.   I know there is a
sendkeys command but I can't find any documentation on it.   I'll
probably have to bite the bullet and remove the header information
from the word templates but I hope there is a cleaner solution.

Thanks
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy