Macro or AutoCorrect Entries?

A

Alan B.

I'm creating a medical report template in Word 2003 as a protected form with
various editable text fields, dropdown list entries, and date calculations
which would enable users to quickly tab, or use the arrow keys, to move
through the form to add the pertinent patient information in each field.
There are certain fields where the user enters a 3 - 5 character
alphanumeric code which serves as a lookup for a full 2 or 3 sentence
description of the corresponding medical procedure that replaces the entered
code in the form.
Searching through Auto Text entries for the full description of each
procedure would become tiresome to the users as they would have to look
through all the entries (20-some pages worth) to find the correct one. So, I
decided to try AutoCorrect entries using the code for the "Replace:" item and
the full procedure description as the "With:" item in the AutoCorrect Options
tool. However, AutoCorrect entries are limited to only 255 characters and
many of the procedure descriptions are longer. Is there a way to override
this limit?...a better way of working this capability into the template?
In Word Perfect I was able to create a separate text file of the codes and
descriptions, and then set up a template macro that did a search and replace
from this text file when the code was entered in the template. I can't seem
to be able to make that work in Word because the macro will not run or the
text file will not open, or both. First, the macro hangs when I try to run it
when the template is protected. And second, I don't see any VBA code in the
macro file that indicates Word is attempting to open the other file (the text
file with the procedure descriptions) when it runs.
If anyone has a suggestion or an alternative any information would be
greatly appreciated.
 
J

Jezebel

Persevere with the macro. By the sounds of it, you haven't yet mastered the
nuts and bolts ... they will certainly do what you're looking for. Macros
don't hang because the form is protected; they hang because there's
something wrong, either with the code or with the files they are trying to
access. No idea what you mean by "don't see any VBA code in the
template" --- where did you put the code?
 
G

Greg Maxey

Alan,

If the full descriptions are saved as AutoText entries in the template,
then you code use an on exit macro from the "code" field replace the
code with the AutoText entry. Something like:

Sub OnExitCodeField()
Dim oFFld As Word.FormFields
Set oFFld = ActiveDocument.FormFields
Select Case oFFld("Text1").Result
Case Is = "A1234"
oFFld("Text1").Result =
ActiveDocument.AttachedTemplate.AutoTextEntries("A1234").Value
Case Is = "B1234"
oFFld("Text1").Result =
ActiveDocument.AttachedTemplate.AutoTextEntries("B1234").Value
Case Else
'Continue case statements as appropriate
End Select
End Sub
 
A

Alan B.

Hi Jezebel,

Thanks a bunch for responding! I'm not very profficient at working with VBA
or Word macros yet so I simply try to create macros by recording my
keystrokes and mouse selections, and then I examine the macro file to learn
what's going on. When I mentioned the missing VBA code in my original post I
was looking in the macro file, not the template, for some reference or
attempt by the macro at opening the text descriptions file, and I didn't find
either. The code stopped just before I recorded opening the text file and
started back up when I got back in the description field in the template
where the text was to be inserted.

As far as macros not hanging in protected forms, I had set up a field in the
template to calculate a patient's age from their birthdate, which was entered
in another field, and it worked fine until I protected the form. I kept
getting an error message that I was trying to access a protected area, when I
was actually manipulating the data in editable fields.

Thanks again for your help.
 
A

Alan B.

Hi Greg,

With my limited knowledge of code I think I see what you are doing in your
suggested macro...using a Find & Replace routine. I was not aware that one
could access Auto Text without going to the menu or using the toolbar button
each time. I'll try your macro with a subset of the actual codes and
descriptions (there are 152 codes at the present time) to see if the result
is as required. If this works I can see I have a lot of keying-in to do.

Many Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top