changing the mailmerge source file at startup

J

Jeremy

I have a word document that uses a merge file in the c:\ root
directory ( I inherrited this) which is put there by another app.

and now I need to run this via terminal server. so if two people
create this file, chaos will ensue.

so I was thinking of putting this file into the %userprofile%
directory

however, word likes to know the name of this file in advance. I have
tried a macro to change the
activedocument.mailmerge.datasource.querystring but this doesn't work.
does anybody have a better solution?

thanks in advance.
 
C

Cindy M -WordMVP-

Hi Jeremy,

The usual approach would be to save the document without a link to the
data source, then just link up the data on open. If you tell us which
version of Word you'd use to edit the document, we can give you more
detailed pointers :)
I have a word document that uses a merge file in the c:\ root
directory ( I inherrited this) which is put there by another app.

and now I need to run this via terminal server. so if two people
create this file, chaos will ensue.

so I was thinking of putting this file into the %userprofile%
directory

however, word likes to know the name of this file in advance. I have
tried a macro to change the
activedocument.mailmerge.datasource.querystring but this doesn't work.
does anybody have a better solution?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
J

Jeremy

Cindy M -WordMVP- said:
Hi Jeremy,

The usual approach would be to save the document without a link to the
data source, then just link up the data on open. If you tell us which
version of Word you'd use to edit the document, we can give you more
detailed pointers :)


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)


This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)

we are using office xp and win2000, hope that is enough info

Jeremy
 
D

Doug Robbins - Word MVP

Hi Jeremy,

In the mailmerge main document, open the Mailmerge Helper and in Section 1
of the Helper, click on Create and select Restore to Normal Word Document.
While the mailmerge fields will be retained in the document, the link to the
datasource will be removed.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
C

Cindy M -WordMVP-

Hi Jeremy,

Further to Doug's response:

Then use the macro recorder to record linking up to the data source, in
order to get the syntax you need. Alter the code, adding a variable where
you can store the user profile location. Substitute this everywhere in the
OpenDataSource method where the file path to the data source appears. Name
the macro AutoOpen so that it will execute when the user opens the document,
and make sure it's saved IN the document (and not in your Normal.dot).

If you're really using a template, and the users should create a new
document from the template, then name the macro AutoNew and save it IN the
template. If users are likely to need such a document at the same time, you
will need to use a template.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
J

Jeremy

That all works fine!

I removed the original file (in the c:\ directory) open the document,
where word complained that the mail merge source was missing, if you
click the options button, you have the oportunity to remove all mail
merge information.



then some code in the autoopen macro of the document (not normal.dot)
you can create it if it isn't there pointed the mail merge to the
right place

Dim userprofile As String

userprofile = Environ("userprofile")
ActiveDocument.MailMerge.OpenDataSource Name:=userprofile +
"\<merge_file>"

Thanks for all the help

Jeremy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top