Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Andrew Duncan Andrew Duncan is offline
external usenet poster
 
Posts: 2
Default Dynamically setting the path to the data source

Does anyone know of a way to dynamically set the path to the data source for
a Word 2003 mail merge letter? For example if you had 50 letters all
pointing to a data source at:

C:\datasource.csv

is there an easy way to change it to find the datasource at:

D:\datasource.csv

without having to change it for each of the 50 letters?

Thanks,
Andrew


  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Dynamically setting the path to the data source

Using a modification of the code in the article "Find & ReplaceAll on a
batch of documents in the same folder" at:

http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

you could attach the new data source to each of the mail merge main letters.


--
Hope this helps.


Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Andrew Duncan" wrote in message
...
Does anyone know of a way to dynamically set the path to the data source
for a Word 2003 mail merge letter? For example if you had 50 letters all
pointing to a data source at:

C:\datasource.csv

is there an easy way to change it to find the datasource at:

D:\datasource.csv

without having to change it for each of the 50 letters?

Thanks,
Andrew



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Microsoft Newsserver Microsoft Newsserver is offline
external usenet poster
 
Posts: 13
Default Dynamically setting the path to the data source

Thanks for your reply Doug. I've been reading that article which looks
promising, however as I understand it the Find&Replace dialog lets you
replace text in the document. I can't see how to use the Find&Replace to
replace the stored location of the data source - the only way I know how to
change this is to either use the Mail Merge Wizard at step 3 or click "Open
Data Source" on the Mail Merge toolbar.

If there's another way to set this I'd love to know.

Many thanks,
Andrew


"Doug Robbins - Word MVP" wrote in message
...
Using a modification of the code in the article "Find & ReplaceAll on a
batch of documents in the same folder" at:

http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

you could attach the new data source to each of the mail merge main
letters.


--
Hope this helps.


Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Andrew Duncan" wrote in message
...
Does anyone know of a way to dynamically set the path to the data source
for a Word 2003 mail merge letter? For example if you had 50 letters all
pointing to a data source at:

C:\datasource.csv

is there an easy way to change it to find the datasource at:

D:\datasource.csv

without having to change it for each of the 50 letters?

Thanks,
Andrew





  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Dynamically setting the path to the data source

It might be simpler to move the data file to the same folder as the merge
document. It should find it there no matter where it was added from.

--

Graham Mayor - Word MVP

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


Microsoft Newsserver wrote:
Thanks for your reply Doug. I've been reading that article which looks
promising, however as I understand it the Find&Replace dialog lets you
replace text in the document. I can't see how to use the Find&Replace
to replace the stored location of the data source - the only way I
know how to change this is to either use the Mail Merge Wizard at
step 3 or click "Open Data Source" on the Mail Merge toolbar.

If there's another way to set this I'd love to know.

Many thanks,
Andrew


"Doug Robbins - Word MVP" wrote in message
...
Using a modification of the code in the article "Find & ReplaceAll
on a batch of documents in the same folder" at:

http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

you could attach the new data source to each of the mail merge main
letters.


--
Hope this helps.


Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Andrew Duncan" wrote in message
...
Does anyone know of a way to dynamically set the path to the data
source for a Word 2003 mail merge letter? For example if you had 50
letters all pointing to a data source at:

C:\datasource.csv

is there an easy way to change it to find the datasource at:

D:\datasource.csv

without having to change it for each of the 50 letters?

Thanks,
Andrew



  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Dynamically setting the path to the data source

I wasn't suggesting using Find & Replace. The purpose for pointing you to
that article was for the way in which it deals with opening each of the
files in a folder, then performing an operation on the file before saving
and closing it. You would need to replace the code in the article that does
the Find & Replace with the appropriate code for attaching the new
datasource to each file.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Microsoft Newsserver" wrote in message
...
Thanks for your reply Doug. I've been reading that article which looks
promising, however as I understand it the Find&Replace dialog lets you
replace text in the document. I can't see how to use the Find&Replace to
replace the stored location of the data source - the only way I know how
to change this is to either use the Mail Merge Wizard at step 3 or click
"Open Data Source" on the Mail Merge toolbar.

If there's another way to set this I'd love to know.

Many thanks,
Andrew


"Doug Robbins - Word MVP" wrote in message
...
Using a modification of the code in the article "Find & ReplaceAll on a
batch of documents in the same folder" at:

http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

you could attach the new data source to each of the mail merge main
letters.


--
Hope this helps.


Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Andrew Duncan" wrote in message
...
Does anyone know of a way to dynamically set the path to the data source
for a Word 2003 mail merge letter? For example if you had 50 letters all
pointing to a data source at:

C:\datasource.csv

is there an easy way to change it to find the datasource at:

D:\datasource.csv

without having to change it for each of the 50 letters?

Thanks,
Andrew









  #6   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Microsoft Newsserver Microsoft Newsserver is offline
external usenet poster
 
Posts: 13
Default Dynamically setting the path to the data source

Hi Doug,

Thanks again - do you know of any reference for the details for appropriate
code for updating the location of the datasource?

Andrew



"Doug Robbins - Word MVP" wrote in message
...
I wasn't suggesting using Find & Replace. The purpose for pointing you to
that article was for the way in which it deals with opening each of the
files in a folder, then performing an operation on the file before saving
and closing it. You would need to replace the code in the article that
does the Find & Replace with the appropriate code for attaching the new
datasource to each file.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Microsoft Newsserver" wrote in message
...
Thanks for your reply Doug. I've been reading that article which looks
promising, however as I understand it the Find&Replace dialog lets you
replace text in the document. I can't see how to use the Find&Replace to
replace the stored location of the data source - the only way I know how
to change this is to either use the Mail Merge Wizard at step 3 or click
"Open Data Source" on the Mail Merge toolbar.

If there's another way to set this I'd love to know.

Many thanks,
Andrew


"Doug Robbins - Word MVP" wrote in message
...
Using a modification of the code in the article "Find & ReplaceAll on a
batch of documents in the same folder" at:

http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

you could attach the new data source to each of the mail merge main
letters.


--
Hope this helps.


Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Andrew Duncan" wrote in message
...
Does anyone know of a way to dynamically set the path to the data
source for a Word 2003 mail merge letter? For example if you had 50
letters all pointing to a data source at:

C:\datasource.csv

is there an easy way to change it to find the datasource at:

D:\datasource.csv

without having to change it for each of the 50 letters?

Thanks,
Andrew









  #7   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Dynamically setting the path to the data source

Sub UpdateDataSource()

Dim MyPath As String
Dim MyName As String
Dim MyDoc As Document
'let user select a path
With Dialogs(wdDialogCopyFile)
If .Display() -1 Then Exit Sub
MyPath = .Directory
End With

'strip quotation marks from path

If Len(MyPath) = 0 Then Exit Sub

If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2) End If

'Open each file from the selected path and 'attach the mailmerge data source
to it.

MyName = Dir$(MyPath & "*.doc")
Do While MyName ""
Set MyDoc = Documents.Open(MyPath & MyName)
With MyDoc
.MailMerge.OpenDataSource "D:\datasource.csv"
.Save
.Close
End With
MyName = Dir
Loop

End Sub

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Microsoft Newsserver" wrote in message
...
Hi Doug,

Thanks again - do you know of any reference for the details for
appropriate code for updating the location of the datasource?

Andrew



"Doug Robbins - Word MVP" wrote in message
...
I wasn't suggesting using Find & Replace. The purpose for pointing you to
that article was for the way in which it deals with opening each of the
files in a folder, then performing an operation on the file before saving
and closing it. You would need to replace the code in the article that
does the Find & Replace with the appropriate code for attaching the new
datasource to each file.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Microsoft Newsserver" wrote in message
...
Thanks for your reply Doug. I've been reading that article which looks
promising, however as I understand it the Find&Replace dialog lets you
replace text in the document. I can't see how to use the Find&Replace to
replace the stored location of the data source - the only way I know how
to change this is to either use the Mail Merge Wizard at step 3 or click
"Open Data Source" on the Mail Merge toolbar.

If there's another way to set this I'd love to know.

Many thanks,
Andrew


"Doug Robbins - Word MVP" wrote in message
...
Using a modification of the code in the article "Find & ReplaceAll on a
batch of documents in the same folder" at:

http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

you could attach the new data source to each of the mail merge main
letters.


--
Hope this helps.


Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Andrew Duncan" wrote in message
...
Does anyone know of a way to dynamically set the path to the data
source for a Word 2003 mail merge letter? For example if you had 50
letters all pointing to a data source at:

C:\datasource.csv

is there an easy way to change it to find the datasource at:

D:\datasource.csv

without having to change it for each of the 50 letters?

Thanks,
Andrew











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
How to make mail merge independent from source file path? Mohammad Fouz Salah Mailmerge 1 August 7th 06 09:56 AM
Detach or change SQL data source for Word template, and other Qs SJMac Mailmerge 6 July 27th 06 10:12 AM
Editing Data source Greg Mailmerge 1 July 26th 06 12:00 AM
Unable to change data source [email protected] Mailmerge 0 October 12th 05 06:02 PM
Merge Data Source path Peter Jamieson Mailmerge 0 November 25th 04 08:15 PM


All times are GMT +1. The time now is 12:31 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"