Thank you for your guideline. I've done my macro homework since no one of my
colleagues would reconnect the data source by hand and single-handed. And
there is one more question:
While opening the source with the macro, a user has to go through the same
dialogue as if doing it by hand, e.g. he has to choose a sheet in the excel
file containing data. Is there a way to make macro do it in 'silent' mode,
eliminating all the dialogue with a user?
PS: again, it's word 2003
As long as you know the sheet name, you should be able to specify it in the
SQLStatement. For example, the following OpenDataSource call should open the
first sheet in a typical Excel workbook where none of the sheets has been
renamed:
ActiveDocument.MailMerge.OpenDataSource _
Name:= "C:\Documents and Settings\myname\My Documents\My Data
Sources\kt.xls", _
Connection:= "", _
SQLStatement:="SELECT * FROM `Sheet1$`"
(Notice that you do not usually need anything in the Connection parameter,
and that if you found out what the OpenDataSource should look like by
recording a macro, the Connection parameter that Word records is typically
invalid as it is truncated. It may still work, though). Also, you don't
usually seem to need the SubType parameter, although wdMergeSubTypeAccess is
the one Word records).
If you do that, Word should not prompt the user for the sheet name.
Peter Jamieson
> Thank you for your guideline. I've done my macro homework since no one of
> my
[quoted text clipped - 40 lines]
>> > place the main document resides?
>> > (using Office 2003)
George Lagger - 27 Jan 2005 13:55 GMT
Thank you A LOT!-)
The recorded macro showed a parameter in OpenDataSource which I could not
find in HELP :
SubType:=wdMergeSubTypeAccess
it was inserted after SQLStatement:="SELECT * FROM `Sheet1$`",
and that did the trick!
> As long as you know the sheet name, you should be able to specify it in the
> SQLStatement. For example, the following OpenDataSource call should open the
[quoted text clipped - 62 lines]
> >> > place the main document resides?
> >> > (using Office 2003)