Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving the path of a Word file automatically in Access

Status
Not open for further replies.

timnicholls

Technical User
Oct 31, 2003
43
0
0
AU
Hi All,

This is a repost of a message from November. I have been working on this for a while and need further input.

I have a merge for an individual document going out to Word.

All is working well.

I am having trouble saving the documents path automatically and updating a subform field (with the path) with each new document for each seperate client.

I do not know how to update the recordset for a new record and place the path
in the proper place. I have it set up to do it manually, you can press the "+" button to
open a dialog and find the document after you have saved it to a common file,
but I would like to automatically save the document and the path at the same time.
(When the document closes)

The coding I have so far is not all mine, but it works.

I think I should be using Application.ActiveDocument.Close to do something after Word closes then Application.ActiveDocument.FullName to get the path of where the document was saved...

A demo database can be dowloaded from me here:

All the important code is behind the cmdWord Button I think.

Can I ask a couple of people to have a look?
A couple of demo Word templates are also included so everything works as it should (so far anyway)

Thanks
Tim
 
do you know which directory it is to be saved in ? I suspect that's what you want anyway.

Before the save command, issue the line

pappword.ChangeFileOpenDirectory <Directory Path >

This way you are telling word where to save it as oppose to having to ask word where it saved it.

Any good ?

BuilderSpec
 
Hi Tim.
I think I should be using Application.ActiveDocument.Close to do something after Word closes then Application.ActiveDocument.FullName to get the path of where the document was saved...


Almost correct - it's vice-versa. Else the document is closed and has no longer a full name... ;-)

Update:
Code:
DoCmd.SetWarnings False
DoCmd.RunSQL &quot;UPDATE your table SET [WordPath]='&quot; & Wrd.ActiveDocument.FullName & &quot;' WHERE [RecordId]=&quot; & Me![RecordID]&quot;
DoCmd.SetWarnings True

Be sure to backup your db before perfoming unsecure UPDATEs.

MakeItSo

Andreas Galambos
EDP / Technical Support Specialist
(andreas.galambos@bowneglobal.de)
HP:
 
BuildSpec,

We know which directory it is to be saved in, but the directory changes with each client.
Client Joe Bloggs has a folder &quot;Bloggs, J&quot;, etc. So a hardcoded path may not be the correct option...yet :)


Andreas,

Is it at all possible for you to have a look at the database, available from the link in my first post, to see where your code,

DoCmd.SetWarnings False
DoCmd.RunSQL &quot;UPDATE your table SET [WordPath]='&quot; & Wrd.ActiveDocument.FullName & &quot;' WHERE [RecordId]=&quot; & Me![RecordID]&quot;
DoCmd.SetWarnings True


would go.

I am having an awful lot of trouble putting the SQL into practice.

Thank You both for helping.

Tim

 
Let me ask you this.. why do you want to save the path ?

if you have a client called Joe Bloggs and all his stuff gets saved to this folder. Isn't that enough ? You know all Joe Bloggs stuff is without having to save it ? no ?

BuildSpec
 
BuildSpec,

Everything you say is correct.

However I have a problem in that the subform on the form (in the demo) I would like to make a sort of document management area.

It keeps track of all the documents and is the only way a user should be able to access the documents again once they have been saved in the folder. Thus the need for a path. It links the document to the person (Client) in Access.

If only I knew how to make the link automatic :)

Tim
 
Thing is this...

I have created a document manager thing before.. where is saves all the docs etc within the database.

You say that it's the only way to change the docs.. it ain't ! If Access knows where it is then you can bet your users will.. if they delete a document thru explorer etc then you have a funny situation since the database still think it's there when it aint !

What might be better is that since you know what directory the docs are in , even though you don't want to broadcast that info. Why not show what documents are available by querying the directory as opposed to the database ?

BuilderSpec
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top