View Single Post
 
Old 04-05-2015, 08:53 AM
jer85's Avatar
jer85 jer85 is offline Windows 7 32bit Office 2010 32bit
Novice
 
Join Date: Mar 2015
Location: Budapest, Hungary
Posts: 2
jer85 is on a distinguished road
Default Macro to keep formatted form fields after mail merge or replace text with formatted form fields

Hi,

Could I please ask for a little help? I'm really stuck with a thing and I'm not familiar with VBA in Word, however it would be very important for me. Actually I would have 2 questions. A solution for Problem 1 would be the ideal for me but I realize that it might be a very difficult request. If it's not possible, a solution for Problem 2 would make me also happy and grateful.

Problem 1)
I have a document with empty form fields and I have a database which contains information for some of these fields. I would like to execute a merge mail, my goal is to import data from the database to the relevant fields (leaving intact the remaining fields), but I would like to achieve the following 3 goals at the same time:
- I would like to insert the merge mail fields into the specific form fields (not overwriting them) so as that after merge mail they still could be edited. It might be possible that the database has some data which are not up to date so I would like to give the user the opportunity to edit the imported data in fields (while the overall document would be protected of course).
- after merge mail I would also like the blank form fields to be preserved, so they could be edited after protecting the document. As I experienced, Word deletes the form fields after merge mail by default.
- my form fields have different charcter masks, e.g. allowing only 1 digit numbers, 2 digit numbers or plain texts to be input. I would really like to keep these format rules after merge mail.

Problem 2)
Supposing that it’s not possible to keep form fields when doing merge mail, I would place specific character combinations in the original document as a sign for future wanted form fields (e.g. „ff1”, „ff2”, „fft”). After merge mail is done, I would execute a code to find these character sets and replace them with form fields. What code should I use if I want each instance of „ff1” to be replaced with 1 digit, number only form fields, „ff2” with 2 digit, number only form fields and „fft” with plain text form fields? This way the users unfortunately would not have the opportunity to edit the data imported, but the blank form fields could be still edited (hence I can protect the document) which is a half success.

I really appreciate any help and the time you spend to answer me!
Thanks,
Roland
Reply With Quote