Thread: Macro Failure
View Single Post
  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Macro Failure

This merge issue has been kicking around in several of the Word forums. It
would cut out a lot of duplication of effort if you stuck to the one forum.
Those of us who contribute to the Word forums tend to contribute to most of
them.

As you are opening a merge document to populate it by macro, it would make a
lot more sense to simply create the merge document with the fields already
added. You can then attach your data source and complete the merge.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Curt wrote:
error code 5638 could not parse query options valid query string
This has got me. Not sure if a memory problem in machine or what.
This was all built with macro recorder.
Also I could not open web site from notfication had to go around to
get back to you. All I got was a blank screen.
Thanks for assistance

Sub Macro2()
'
' Macro2 Macro
' Macro recorded 5/24/2008 by Curtiss A. Greer
'
ChangeFileOpenDirectory "C:\Parade\"
Documents.Open FileName:="Letter.doc", ConfirmConversions:=False,
ReadOnly _
:=False, AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate _
:="", Revert:=False, WritePasswordDocument:="",
WritePasswordTemplate:="" _
, Format:=wdOpenFormatAuto
Selection.MoveDown Unit:=wdLine, count:=1
Selection.TypeParagraph
Selection.TypeParagraph
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:="C:\Parade\ZZZ.txt",
_ ConfirmConversions:=False, ReadOnly:=False,
LinkToSource:=True, _ AddToRecentFiles:=False,
PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="",
Revert:=False, _ Format:=wdOpenFormatAuto, Connection:="",
SQLStatement:="",
SQLStatement1 _
:=""
ActiveDocument.MailMerge.EditMainDocument
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:=
_ "Name_of_Entry"
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:=
_ "Contact_Person"
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:=
_ "Address"
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:=
_ "CityState"
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range,
Name:="Zip_" Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range,
Name:="Amount" ActiveDocument.MailMerge.datasource.QueryString = _
"SELECT * FROM C:\Parade\ZZZ.txt WHERE ((Name_of_Entry IS NOT
NULL ) AND (Contact_Person IS NOT NULL ) AND (Address IS NOT NULL )
AND (City State IS NOT NULL ) AND (Zip_ IS NOT NULL ) AND (Amount IS
NOT NULL ))" _ & ""
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = False
With .datasource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
CommandBars("Control Toolbox").Visible = False
CommandBars("Stop Recording").Visible = False
End Sub




"Graham Mayor" wrote:

Post the code?

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Curt wrote:
Build a text file and do a merge from it and all is fine. In fact I
did 4 options from in this manner. Now a few days later when I run
the same macro it fails. Cannot parse string. same error in all.
What would change when nothing has been changed in operation. If
macro will not continue to function how can a person lock in action
so it will continue in operation.
Can rebuild macros but that shouldn't be necessary.
Any ideas help.
Thanks