Pathname is clientnumber (MergeField)

J

jasper.nijkamp

Hello!

Im in the following situation:

I wrote a macro with sets the name of the document to the date and
subject from the letter.
and when you run the macro, word will merge the letter to a new
document (so you'll lose the connection to the crm system) and you'll
automaticly get the SaveAs window. However, i want word to automaticly
select a certain pathname aswell.

Lets say i want the clientnumber to be the pathname.
Word gets the MergeField clientnumber from a crm system we use.

For example:
if the clientnumber is 12345
i want the path to be C:\clients\12345\

is this possible?
If it is, what should the code look like?

Thanks in advance.
Kind regards,
Jasper Nijkamp
 
J

John McGhie

Hi Jasper:

Generically it's a single line:

ActiveDocument.SaveAs FileName:="C:\clients\12345\12345.doc"

SaveAs will take either a filename on its own, or a complete path. Note the
quotes: they are critical if the pathname contains any spaces.

The caveat is that the path you specify must already exist. For
safety/sanity you would include a ChDir command to change to your intended
path, then a CurDir command to check that the current directory returned
matches the one you changed to. If it doesn't, the folder you want doesn't
yet exist, use MkDir to create it.

These examples are in the VBA Help.

Cheers


Hello!

Im in the following situation:

I wrote a macro with sets the name of the document to the date and
subject from the letter.
and when you run the macro, word will merge the letter to a new
document (so you'll lose the connection to the crm system) and you'll
automaticly get the SaveAs window. However, i want word to automaticly
select a certain pathname aswell.

Lets say i want the clientnumber to be the pathname.
Word gets the MergeField clientnumber from a crm system we use.

For example:
if the clientnumber is 12345
i want the path to be C:\clients\12345\

is this possible?
If it is, what should the code look like?

Thanks in advance.
Kind regards,
Jasper Nijkamp

--
Don't wait for your answer, click here: http://www.word.mvps.org/

Please reply in the group. Please do NOT email me unless I ask you to.

John McGhie, Consultant Technical Writer
McGhie Information Engineering Pty Ltd
http://jgmcghie.fastmail.com.au/
Sydney, Australia. S33°53'34.20 E151°14'54.50
+61 4 1209 1410, mailto:[email protected]
 
J

jasper.nijkamp

Hi Jasper:

Generically it's a single line:

ActiveDocument.SaveAs FileName:="C:\clients\12345\12345.doc"

SaveAs will take either a filename on its own, or a complete path. Note the
quotes: they are critical if thepathnamecontains any spaces.

The caveat is that the path you specify must already exist. For
safety/sanity you would include a ChDir command to change to your intended
path, then a CurDir command to check that the current directory returned
matches the one you changed to. If it doesn't, the folder you want doesn't
yet exist, use MkDir to create it.

These examples are in the VBA Help.

Cheers









--
Don't wait for your answer, click here:http://www.word.mvps.org/

Please reply in the group. Please do NOT email me unless I ask you to.

John McGhie, Consultant Technical Writer
McGhie Information Engineering Pty Ltdhttp://jgmcghie.fastmail.com.au/
Sydney, Australia. S33°53'34.20 E151°14'54.50
+61 4 1209 1410, mailto:[email protected] Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -

Thanks for the help, but i don't need it anymore :) maybe someone else
can use it.

Due to an update of our crm system, i only had to set the Openfiledir
to K:\Clients and the program itself finds the right path based on the
clientinformation in the letter (in this case).

Greetings
 
J

John McGhie

Hi Jasper:

Well, that's a relief. Probably the first time I have heard of an update to
a CRM system actually adding a *useful* feature, but there you go :)

Cheers


Thanks for the help, but i don't need it anymore :) maybe someone else
can use it.

Due to an update of our crm system, i only had to set the Openfiledir
to K:\Clients and the program itself finds the right path based on the
clientinformation in the letter (in this case).

Greetings

--
Don't wait for your answer, click here: http://www.word.mvps.org/

Please reply in the group. Please do NOT email me unless I ask you to.

John McGhie, Consultant Technical Writer
McGhie Information Engineering Pty Ltd
http://jgmcghie.fastmail.com.au/
Sydney, Australia. S33°53'34.20 E151°14'54.50
+61 4 1209 1410, mailto:[email protected]
 

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