SELECT Students.Last_Name, Students.First_Name, Students.Middle_Name, Students.Address_1, Students.Address_2, Students.City, Students.State_Province, Students., Students.Country_Region, Students.File_Status, Students.Admit_Type, Students.SubPlan, This is the query (named Letter_1) for one of the letters: I may not be able to get back to you until Monday, but it would be good to get the SQL statement from you today if possible. If any of the steps cannot be performed within the Document_New event procedure, I'm sure it will still be possible to create a button within the Word document that the user can click to perform these extra steps after the document has appeared to the user. I shall experiment with this and let you know. I think steps (a) to (e) could be performed in the Document_New event procedure, but I'm not sure about steps (f) to (h). I am familiar with performing all these steps from within Access. (h) show a message to the user that the merge is complete.
(e) link the template to the newly-created temporary data source Is probably faster and probably doesn't require Excel to be installed - not sure about that, but it seems likely) (d) use the query to export the data to a temporary Excel or rich-text file (you're using Excel, but my text book uses a rich-text file - I don't think it matters much - rich-text (c) prompt the user for the required parameters and pass the parameters to the query
#FILE PERMISSION ERROR WORD 2010 CODE#
I think exporting the data is probably a good idea in your situation, but I'll think about this further.Īs I think your users are starting Microsoft Word and creating a new Word document from an existing Word template, it would seem (focusing for the moment on the current situation) that the best solution would be to write code in the template's Document_NewĮvent procedure and for this code to perform the following steps (this will happen each time a new document is created from the template): There is a reason why the data is first exported (either to an Excel file or a rich-text file) and why the merge is then executed between the template and the exported data. However, if you successfully program the process, the program will execute the intermediate steps effortlessly and you won't care very much how the final result is achieved - just that it is achieved! I see why you would want to eliminate as many steps as possible for a merge that is performed manually. > the second step (having to export the result to an excel file).
use the excel file to do the mail merge.> with the least possible clicks for users. > The template (in this case, the letter) isn't set up to merge.Ĭould you please post the SQL statement for the parameter query? (Open the query in design view, click View > SQL View then copy the SQL statement and post it back to the forum.) > for each person (selected by the parameter query). > Users have pre-written letter that must be customized I'll try to give some further suggestions and coding examples when you reply to the above questions. I've not looked through it but you may like to start browsing here: There is also information on the website. The previously mentioned "Access Cookbook" will give you all the information you need to run a merge programmatically from an Access database. Can you provide any other relevant informaton on how the merge currently works? Is it necessary to display a list of data, say Client IDs/names, stored in the Access database in order for the user to select the appropriate parameter value?Ħ.Do you need to get a parameter value out of the Access database, e.g.Alternatively, are the parameter values a bit more complicated? For example: Are the parameter values simple bits of data that the user can enter using the keyboard?ĥ. What are the parameters required by the query?Ĥ. I assume users are not clicking a button in Access that starts Word, creates a new document based on a mail merge Word template.ģ. Are users using Word to create a new document from a Word template? And is the template already set up to merge with a parameter query in an Access database?Ģ. I don't have choice as far as where to start the mail merge.ġ.