External data

L

Lina

Hi!

I have a folder with several Word files. I open them by code, replace
some stuff in text, and then close them again.

The problem is that there are some Word files in the folder who need
external data. I am forced to work with Word 97. Once you open such
file, you are obliged to choose a data source. The problem is dat
these are template documents and may not be changed!

Is there any way I can avoid this, maybe closing the file without
having to find a datasource?

Many thanks in advance,
Lina.

PS: The program should work for several document folders, so searching
all documents with external data between more than 500 files manually
is not an option.
 
C

Chuck

I don't have Word97 available but you could try playing around with the
MailMerge object. For instance, the following code should check whether the
activedocument is a Main document (without a data source attached) and close
the document if so:

If ActiveDocument.MailMerge.State = wdMainDocumentOnly Then
ActiveDocument.Close wdDoNotSaveChanges
End If

You could use Word Help to explore the MailMerge properties/methods further...

Sorry can't be of more assistance, maybe someone else has a better idea.
 
C

Cindy M -WordMVP-

Hi Lina,
I have a folder with several Word files. I open them by code, replace
some stuff in text, and then close them again.

The problem is that there are some Word files in the folder who need
external data. I am forced to work with Word 97. Once you open such
file, you are obliged to choose a data source. The problem is dat
these are template documents and may not be changed!

Is there any way I can avoid this, maybe closing the file without
having to find a datasource?
Not really with Word97. Problem is, apparently, that these are linked
to a datasource path that the files are no longer able to find. Best
you could do would be to have your code set a timer and, if things
don't progress within a certain period of time, use SendKeys to dismiss
any message boxes holding things up. This is the only way to automate
office applications without any user intervention. There's Knowleged
Base article you can find at msdn.com on this subject. It's written for
VB6.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
Top