Reply
 
Thread Tools Display Modes
  #1   Report Post  
George Lagger
 
Posts: n/a
Default DataSource in the folder of the main document

My main document often migrates from one location to another along with the
source Excel file. While merging it keeps remembering an old path to the
source. So it either finds the file with wrong data or doesn't find it at
all. Can I by any means make it look for the data source file in the same
place the main document resides?
(using Office 2003)
  #2   Report Post  
Peter Jamieson
 
Posts: n/a
Default

I don't believe there is a way to do this without resorting to a macro,
which would probably mean that
a. your document would need to be saved as a non-mailmerge document
b. the macro would need to set the document to be a mailmerge document of
the type you needed, then
c. open the data source (this may be ewasy or difficult depending on the
version fo word, the data source etc.
d. restore any sort/filter options you might need. Again, this may or may
not be straightforward depending on what options you have set

In short, if you are comfortable with macros, it may be feasible. If you are
not, it's probably simpler and more reliable to reconnect the data source by
hand.

Peter Jamieson

"George Lagger" wrote in message
...
My main document often migrates from one location to another along with
the
source Excel file. While merging it keeps remembering an old path to the
source. So it either finds the file with wrong data or doesn't find it at
all. Can I by any means make it look for the data source file in the same
place the main document resides?
(using Office 2003)



  #3   Report Post  
George Lagger
 
Posts: n/a
Default

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

"Peter Jamieson" пишет:

I don't believe there is a way to do this without resorting to a macro,
which would probably mean that
a. your document would need to be saved as a non-mailmerge document
b. the macro would need to set the document to be a mailmerge document of
the type you needed, then
c. open the data source (this may be ewasy or difficult depending on the
version fo word, the data source etc.
d. restore any sort/filter options you might need. Again, this may or may
not be straightforward depending on what options you have set

In short, if you are comfortable with macros, it may be feasible. If you are
not, it's probably simpler and more reliable to reconnect the data source by
hand.

Peter Jamieson

"George Lagger" wrote in message
...
My main document often migrates from one location to another along with
the
source Excel file. While merging it keeps remembering an old path to the
source. So it either finds the file with wrong data or doesn't find it at
all. Can I by any means make it look for the data source file in the same
place the main document resides?
(using Office 2003)




  #4   Report Post  
Peter Jamieson
 
Posts: n/a
Default

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


"George Lagger" wrote in message
...
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

"Peter Jamieson" ?????:

I don't believe there is a way to do this without resorting to a macro,
which would probably mean that
a. your document would need to be saved as a non-mailmerge document
b. the macro would need to set the document to be a mailmerge document
of
the type you needed, then
c. open the data source (this may be ewasy or difficult depending on the
version fo word, the data source etc.
d. restore any sort/filter options you might need. Again, this may or
may
not be straightforward depending on what options you have set

In short, if you are comfortable with macros, it may be feasible. If you
are
not, it's probably simpler and more reliable to reconnect the data source
by
hand.

Peter Jamieson

"George Lagger" wrote in message
...
My main document often migrates from one location to another along with
the
source Excel file. While merging it keeps remembering an old path to
the
source. So it either finds the file with wrong data or doesn't find it
at
all. Can I by any means make it look for the data source file in the
same
place the main document resides?
(using Office 2003)






  #5   Report Post  
George Lagger
 
Posts: n/a
Default

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!

"Peter Jamieson" пишет:

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


"George Lagger" wrote in message
...
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

"Peter Jamieson" ?????:

I don't believe there is a way to do this without resorting to a macro,
which would probably mean that
a. your document would need to be saved as a non-mailmerge document
b. the macro would need to set the document to be a mailmerge document
of
the type you needed, then
c. open the data source (this may be ewasy or difficult depending on the
version fo word, the data source etc.
d. restore any sort/filter options you might need. Again, this may or
may
not be straightforward depending on what options you have set

In short, if you are comfortable with macros, it may be feasible. If you
are
not, it's probably simpler and more reliable to reconnect the data source
by
hand.

Peter Jamieson

"George Lagger" wrote in message
...
My main document often migrates from one location to another along with
the
source Excel file. While merging it keeps remembering an old path to
the
source. So it either finds the file with wrong data or doesn't find it
at
all. Can I by any means make it look for the data source file in the
same
place the main document resides?
(using Office 2003)






Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can you save individual document pages as seperate word files? John Calligy Mailmerge 2 April 12th 05 09:14 AM
Trying to use a .dot document as main document Pat B Mailmerge 12 January 11th 05 12:03 PM
I can't see my sub folder under the main contact folder Bob F Microsoft Word Help 1 January 7th 05 05:08 AM
Mail Merging into the current or target document Viperpurpleuk Mailmerge 1 December 20th 04 08:12 AM
Document object in protected form Bruce Tables 2 December 6th 04 07:09 PM


All times are GMT +1. The time now is 05:00 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"