473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Auto-filling a letter template in Word from fields in a database

109 100+
Hello

I have a letter template in Word that has some blanks. I want to populate these blank spaces with fields from the database. These blanks are:

client name
client address
appointment date
practitioner (sender of the letter)

Ideally, I'd like to add a button to a form and when a user clicks it, it will take the information from the fields in that specific record and fill in the blanks of the letter template.

Is this at all possible? I've been reading about Mail Merge but I'm not sure it will do what I need - it seems to be for more bulk mailing. Also, I've been looking at Word form fields which seems to be what I need but I don't know if my version of Office will work with it properly (well, the code I've tried doesn't seem to recognise 'Word.'). I'm using 2000.

Any help/insight appreciated!
Nov 13 '09 #1
13 14310
ChipR
1,287 Expert 1GB
I can't tell how much effort you've put into this. If you are interested in programming with Word from Access, it will be easier if you have a reference set in Access to Microsoft Word Objects. Then check out Microsoft Word 2000 Reference and Microsoft Word Objects
Nov 13 '09 #2
hedges98
109 100+
Well, being completely clueless on where to begin I've just been googling for help and reading stuff. I understand the basics of it, I think. I have set the reference to Word Objects (cheers, google!)

I have been playing around with using Word Forms and trying to get them to update via Access but the code I found (and tailored to my database) doesn't seem to do anything. I'm toying around with it this afternoon but will probably get stuck again.

Cheers for those links though, ChipR, I'll give them a look.
Nov 13 '09 #3
MMcCarthy
14,534 Expert Mod 8TB
You can also check out our article in the Insights section on Application Automation. Although the examples used are for Excel and Outlook the basic principles stand.

Mary
Nov 13 '09 #4
NeoPa
32,556 Expert Mod 16PB
I think this is all a lot more simple than anyone is giving it credit for.

Look into MailMerge. It is a facility within MS Word. No programming required.
Nov 15 '09 #5
hedges98
109 100+
But isn't Mail Merge used to create bulk letters/messages/whatevers? I only want it to produce one letter when a button is pressed. Is Mail Merge capable of doing that?

From playing around with Mail Merge, I've managed to insert the fields into the template as required but I can't figure out how I'd ensure it only filled labels for the current record/form as opposed to every record stored in the database.
Nov 17 '09 #6
NeoPa
32,556 Expert Mod 16PB
To be honest, it's not something I've used greatly myself, but I do recall the ability to populate only one record of data. Look in the MailMerge toolbar. If the worst comes to the worst, run a bunch and simply select only the one you're interested in. I'm pretty sure there is an option to specify which one you want though if you look.
Nov 17 '09 #7
hedges98
109 100+
You can specify a range of records to merge but I need it to be set to do it manually as it'll be used by a few people who need it automated.

For the time being, I've created a letter template through a report in Access that does the job but ideally, I'd like it to be in Word because it's easier for a user to edit etc.
Nov 17 '09 #8
NeoPa
32,556 Expert Mod 16PB
That makes some sense. Unfortunately, this seems like you need to control Word from within Access. This is possible with Application Automation, though it is far from straightforward.

One benefit with handling development of the Word code is that you can record macros in word which create some (admittedly pretty basic) VBA code for you.

Remember when automating a foreign application that the defaults are not set up in the same way as they would be when running natively.
Nov 17 '09 #9
hedges98
109 100+
Hmm, I think this is way beyond what I'm capable of. I guess I'll just keep it as I have it.

One annoying thing, exporting the report to Word (which would be ideal!) won't work because it loses the formatting and the images on the report don't export with it.
Nov 17 '09 #10
NeoPa
32,556 Expert Mod 16PB
Yes. It's not ideal. The format is actually RTF (Rich Text Format) rather than native Word format as such. Quite limiting really. There's also a Snapshot format which is generally quite unreliable & non-portable, or a PDF option with an Add-In or with later versions. Both of which formats are generally non-updatable anyway though.

Have you considered doing some code from the Word end? It may not be quite as swish as a single-button operation, but you may find it is some help to your users (assuming of course that you are comfortable enough with VBA in Word).
Nov 17 '09 #11
hedges98
109 100+
Ah, rubbish! You'd think they'd export to .doc. Hmm.

I haven't considered coding it from Word because I have no experience in using VBA in Word. I'll show the users what I've done tomorrow as I think it achieves what they want it to do (save them the hassle of switching between Access and Word to enter the client's name and address on a letter template, basically)
Nov 17 '09 #12
NeoPa
32,556 Expert Mod 16PB
A thought just occurred to me. Perhaps it can export using XML (I'm pretty sure Office 2007 uses this extensively). If so, reading that into Word may prove to support more than the basic RTF it uses by default. It's a long-shot, but possibly worth a try.

Good luck.
Nov 17 '09 #13
hedges98
109 100+
I'm using Office 2000, sadly. Plus, I think that's just delving deeper into something I know nothing about! Thanks for the suggestion though
Nov 17 '09 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Lew | last post by:
Hi all, I'm trying to create a page that has a user-selectable page auto-refresh option (IE 5.5). Essentially, it's a page that contains a checkbox, when the user checks the checkbox, I'd like...
1
by: Glabbeek | last post by:
I'm changing the layout of my site. Instead of using tables, I will use DIVs. It's working fine, except for 1 thing: In IE6 some DIVs are not the correct width. Mozilla and Opera are showing the...
5
by: Robert Downes | last post by:
I'm using the following in a page that I'm testing in Mozilla: p.actionLinkBlock {border: 1px #000000 dashed; padding: 0.2cm; width: auto} But the dashed border is extending to the right-edge...
20
by: Vijay Kumar R. Zanvar | last post by:
Hello, Unlike register, auto keyword can not be used to declare formal parameter(s). Is there any specific reason for this? Kind regards, Vijay Kumar R. Zanvar
2
by: VB Programmer | last post by:
I created a page which I am using to prevent the user from hitting the BACK button. I'll call it my "Auto Jump" page. When it is called it basically auto-redirects to a page specified in the...
5
by: Samuel | last post by:
Hi, I am running into a problem of mixing UICulture = auto and allowing users to select culture using a dropdown list. I am detecting a querystring, "setlang", and when found, setting the...
7
by: Brian | last post by:
hello, I am looking for a way to auto refresh a web page that I created, but also let the user choose to stop the auto refresh. I can not figure out how to stop the auto refresh. Any help would...
5
by: maya | last post by:
at work they decided to center divs thus: body {text-align:center} #content {width: 612px; text-align:left; margin: 0 auto 0 auto; } this works fine in IE & FF, EXCEPT in FF it doesn't work if...
22
by: nospam_news | last post by:
I currently get asked about my usage of "auto". What is it for? The keyword is clearly superflous here. In contrast to the huge majority of C/C++ developers I write definitions very explicitly...
21
by: JOYCE | last post by:
Look the subject,that's my problem! I hope someone can help me, thanks
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.