Setting Save Path of Word Document

D

downeyj

I'd like to create a document through the Office API and set the save
path for the document. I do not want to set the default save path for
all documents, just this particular document. And I'd like to do this
without first having to save the document.

I see that when a user creates a document by clicking the new button
on a SharePoint library a new document is created in Word and the save
location is set without changing any of the default save locations for
Word. I can't figure out where in the Word document this value is set.
I don't see anywhere in the Document object to set this value.

Any suggestions would be appreciated. Thanks.
 
L

Luca Brasi

I don't know about setting a value in a document so that Word
automatically uses it as default save path. I guess such an option does
not exist.

But if you have an add-in running (like probably the SharePoint software
does, too) you could catch the BeforeSave event of the Word application
object and check in-there if the active document has a document variable
(defined by you) that contains a path value.

If such a path is found (and it really exists on the local machine),
cancel the default save process and open up the save dialog using
something like Dialogs(wdDialogFileSaveAs). You then can set the default
save path by assigning the path variable to the Name property of the dialog.

In Word 2007, instead of using the BeforeSave event you might want to
reassign a OnAction procedure through the CustomUI.xml.
 

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