B
Bruce Cooley
In Word 2002 I am automating a MailMerge that grabs label info from a named
range in an Excel 2002 file. As long as my range name "LabelData" looks
like this:
='Label Data'!$A$1:$I$75
this single line of code works beautifully:
ActiveDocument.MailMerge.OpenDataSource Name:=PFRGeneratorPathFileName,
Connection:="LabelData", SQLStatement:="SELECT * FROM `LabelData`",
SQLStatement1:=""
However, if I use a dynamic range name like this:
=OFFSET('Label Data'!$A$1,0,0,1+CountRespondents,9)
then the OpenDataSource resorts to a "Select Table" dialog, and even after I
choose the range name, Word fails to access the data.
Since I need this mail merge to grab however many names are in the Excel
file at that time, the dynamic range would be perfect. Am I asking for too
much? Are there any other ways to get around this?
Also, does anyone know why the SQLStatement in the OpenDataSource method
above requires those particular back-slanted "single-quote" marks that came
out of the macro recorder, when it won't work if I substitute ordinary
single quotes?
Thanks in advance,
Bruce
range in an Excel 2002 file. As long as my range name "LabelData" looks
like this:
='Label Data'!$A$1:$I$75
this single line of code works beautifully:
ActiveDocument.MailMerge.OpenDataSource Name:=PFRGeneratorPathFileName,
Connection:="LabelData", SQLStatement:="SELECT * FROM `LabelData`",
SQLStatement1:=""
However, if I use a dynamic range name like this:
=OFFSET('Label Data'!$A$1,0,0,1+CountRespondents,9)
then the OpenDataSource resorts to a "Select Table" dialog, and even after I
choose the range name, Word fails to access the data.
Since I need this mail merge to grab however many names are in the Excel
file at that time, the dynamic range would be perfect. Am I asking for too
much? Are there any other ways to get around this?
Also, does anyone know why the SQLStatement in the OpenDataSource method
above requires those particular back-slanted "single-quote" marks that came
out of the macro recorder, when it won't work if I substitute ordinary
single quotes?
Thanks in advance,
Bruce