earlier thread posted

C

cterryo

I posted a thread earlier and need to update it as there have been additional
details that change the question. Earlier thread questioned use of equal
sign and not equal sign. Update is: that is not where the error is.

The following macro runs:

ChangeFileOpenDirectory "M:\My Documents\"
Documents.Open FileName:="ENGP.DOC", ConfirmConversions:=False, ReadOnly _
:=False, AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate _
:="", Revert:=False, WritePasswordDocument:="",
WritePasswordTemplate:="" _
, Format:=wdOpenFormatAuto
ActiveDocument.MailMerge.DataSource.QueryString = _
"SELECT * FROM MAIL.DBF WHERE ((`STATUS` = 'PP') AND (`RACE` <>
'M'))" _
& ""
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True

This one does not - error message says "run time error 4606, This method or
property is not available because current mail merge main document needs data
source"

ChangeFileOpenDirectory "M:\My Documents\"
Documents.Open FileName:="ENGL1.DOC", ConfirmConversions:=False,
ReadOnly _
:=False, AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate _
:="", Revert:=False, WritePasswordDocument:="",
WritePasswordTemplate:="" _
, Format:=wdOpenFormatAuto
ActiveDocument.MailMerge.DataSource.QueryString = _
"SELECT * FROM MAIL.DBF WHERE ((`STATUS` = 'L1') AND (`RACE` <>
'M'))" & _
""
With ActiveDocument.MailMerge ***(it bombs at this point)***
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
 
S

Suzanne S. Barnhill

As mentioned in the earlier thread, this is not the best NG for this type of
problem. I'm cross-posting to a word.vba NG.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 
P

Peter Jamieson

1. Do both queries return some records?

2. Are the documents being used on the same machine?

3. Are both documents already connected to the data source /before/ you
run the macro?

e.g. if you remove the statement

ActiveDocument.MailMerge.DataSource.QueryString = _
"SELECT * FROM MAIL.DBF WHERE ((`STATUS` = 'PP') AND (`RACE` <>
'M'))" _
& ""

and run the macro, does the merge succeed? And if you remove the
equivalent statement in the other document and run the merge, does the
merge succeed?


Peter Jamieson

http://tips.pjmsn.me.uk
 
C

cterryo

Thank you

Suzanne S. Barnhill said:
As mentioned in the earlier thread, this is not the best NG for this type of
problem. I'm cross-posting to a word.vba NG.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 
C

cterryo

1. No, only the one the runs. If I go into VBA and step thru the one that
does not run it give me an error message at the line indicated. They both
will step thru the line you are asking me to remove.

2. Yes.

3. Yes.

Haven't tried removing the statements but will when I get back in the office
Wed.

There are a series 8 of these macros. They print 4 different letters in
Eng. and 4 in Spanish. All letters print but the first three in English.
The only difference in all 8 commands is the race, status and letter to
retrieve.

As I said in the first thread these macros ran on out of Windows 2000
without any problem. I am now trying to run them on a Windows 98 and a
Windows XP machine. Could there be some type of conflict?
 
P

Peter Jamieson

As I said in the first thread these macros ran on out of Windows 2000
without any problem. I am now trying to run them on a Windows 98 and a
Windows XP machine. Could there be some type of conflict?

At this point I don't know, but
a. are you using the same version of Word on each machine? And FoxPro
(or whatever you are using to maintain your .dbf files)? i.e. what
WIndows/Word/database version combinations are you trying to use?
b. when I asked whether the query returned any records, what I meant
was "if you run that query in Foxpro (or whatever you are using), does
it return any records?" I wondered whether some combinations of
Word+Foxpro will have problems if no records are returned.

What if you change the document that does not work so it has /exactly
the same query/ as one that does (in the .Querystring assignment
statement) ?

The reason I asked the earlier question about whether the document was
already connected is because assigning to Querystring is not enough to
make the connection. You have to use OpenDataSource, or manually open
the data source, for that. However, it is probably significant that
there is no error when you run the .Querystring assignment.

Peter Jamieson
http://tips.pjmsn.me.uk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top