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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create new Word document from template within Access

Status
Not open for further replies.

sirkenj

Technical User
Apr 30, 2002
52
US
I'm trying to figure out a way to open a MS Word document template from within access (from command button) so it opens as a new document. I have it set up currently to open the template, but it actually opens the template for modification, I need it to open a new document from the template. The template has a recordsource within the Access database, the recordsource is a query which is limited by the Access form I want the button on. Everything works great if I select the records I want on my Access form, then open the template by using the "File\New" within word, or if I double-click the .dot file. I really need to automate this though. Anyone who has done this before or knows how I can set it up, your help would be greatly appreciated.
 
If I recall, you must use a document and NOT a template for this to work properly. Can you create a document from the template and save it as a doc? Then use it from Access. I just seem to recall the problem with DOTs...and seem to recall that there wasn't a real method...sorry if I'm wrong. Anne Troy
 
That seems to be the case. It will work using the shell command to open the .dot, but it opens it for modification, not a new document with the template in the background. I can create a .doc with it, but it would work much better for my purposes if it opened the template as a new document. My big concern is that users need to be able to update the .doc / .dot, but should not be able to save the file without specifying a new name for it.....
 
yeah, that's where I'm going with this...part of me won't let me go to sleep at night until I figure this out though...there HAS TO be a way to do this. I tried using a hyperlink, a command button with the shell cmd, everything I can think of. The command line /t(template path) works on a shortcut, but not on a hyperlink??? What gives?

If anyone has some insight they can offer, it would be GREATLY appreciated. I appreciate your prompt response Dreamboat...thanks.
 
A few things I'd do in VB code:
a) make user specify the new filename within Access
b) validate that this new file doesn't already exist
c) copy the .dot file to the new filename.doc

Next steps depend on what flow-of-control you need. Does the user edit the new .doc file? If you just want Word to launch from Access so the user can then do something in Word - easy-easy. If you want to automate Word to do some specific tasks on your new file, it's a little bit more involved...
 
Here's the whole story:
1. Form1 has combo box displaying Last Name, First Name, SSN#. On selecting a name, combo box updates form to show current Last name, First name, SSN#, and a few other fields.
2. Query1 has limiting criteria to only display the SSN# that is currently selected on Form1.
3. WordTemplate.dot has datasource of Query1, displays Last name, First name, SSN, and the other fields which are calculated by Query1 on a form which already has a lot of info on it, some of which may need to be changed by the user. I have default values for a bunch of text boxes / etc. that the end users will often have to change.

There is really no immediate need for the user to be able to save the "new" .doc file, but it often gets emailed, and always gets printed.

So the problem is:
1. I can't find a good way to open WordTemplate.dot from within Form1 without opening it as a .dot file. I need it to open as Document1.doc
2. I haven't really explored the type of permissions the user will need in Access to do this with a DDE connection from word. I know that it works for me with admin settings...I'll cross that bridge when I come to it.

Some things I have tried unsucessfully:
1. Hyperlinking the template...opens as .dot
2. Hyperlinking a shortcut to the template...won't open
3. Hyperlinking a shortcut to Word with the switch /t(Path to WordTemplate.dot)...I know I'm reaching...works for the shortcut, not for the hyperlink
4. Using a command button with the shell cmd to open the template...works, but opens as .dot
5. Praying to God that someone on TekTips has the answer for me...(We'll see how that works out for me...I'll keep you posted)

I believe that is probably all the pertinent information to my problem. I realize I can make the template a .doc and set it up with network security to not allow users to modify the file...it's not the option I'm looking for. Your help will be GREATLY GREATLY appreciated....Thanks
 
Wow, Sirkenj.

This may actually help you!! Helen Feddema is pretty darn respected in the Access arena. This is one of her downloads on "The Word Object Model" and she calls a Word TEMPLATE from Access, among some other code. It just might be right!

ftp://ftp.helenfeddema.com/pub/accarch65.zip

Here's the page I got it from:


Hope it helps! Anne Troy
 
That's exactly what I was looking for...thank you SO much, I knew I wasn't the first person to have this problem.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top