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

Open Word template from Access and pass arguments to AutoNew 1

Status
Not open for further replies.

rwgress

Technical User
Aug 21, 2003
6
US
I am trying to automate creation of a type of bulletin we create. The user selects a part number (or several part numbers) from an Access database and clicks the create button. I want to pass key data from Access to a Word template (through AutoNew).

This existing template already does all that I need it to do, but requires the user to enter a part number, and create bulletins serially. I want to be able to create several bulletins simultaneously by selecting part numbers in Access, and passing them from Access to Word.

Is there a way to pass a variable from Access to Word and open the template? If I set AutoNew() to accept arguments, how can I pass the arguments?

Thanks, rwgress
 
A form. The form shows all eligible PNs and checkboxes for each. The user checks which PNs to create bulletins for. My code will create a recordset of pertinent data, then loop through the recordset. For each record, I want to invoke the Word template and pass the data. The template will then process, save and print. The database will update necessary records, move to the next record in the recordset etc. The problem is, I don't know if I can pass arguments to AutoNew() in a Word template.
 
I don't believe that the AutoNew macro can receive arguments.

What you need to do from Access write a procedure that will Created a new document for each selected Part Number. You will have to set a reference in the VB Editor to the Word Object Library and then in a loop create documents someting like this...
Code:
Dim docNew as Word.Document
Application.DispalyAlerts = False
While ThereArePartNumbers
  Set docNew = CreateObject("Word.Document")
  'whatever you have to do in the Word Doc
  docNew.Save FileName:=strPartNumber & ".doc"
Loop
This might get you in the ballpark. Hope that you can hit a homerun! :)

Skip,
Skip@TheOfficeExperts.com
 
Skip,

Thanks for the advice, it is very helpful. I will see what I can do with it. After a much needed vacation, I realize I don't need to use AutoNew. I can any Sub and send arguments as needed. Now if I can only find the time....

Thanks again.

rwgress
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top