Word forms & WordPad

K

kill_beast

At work, there is an application that lets you create Word documents. It has
some macro that auto-fills in some of it, then you manually fill in some,
then you save it. When you go to view said document in the same application,
for some unknown reason it opens it in WordPad; opens with Word just for
editing (prints like Word too). Normally this is fine because it's just
text, but I'm trying to make it work with form fields, specifically drop down
boxes.

Drop downs don't show up in Word Pad of course. So what I would like to do
is somehow, up saving the document, have it save all of the values selected
as text. I realize this may not be possible, but what I'm trying to avoid is
having to unprotect the document and manually convert from drop down to text.
The reason is that I work for doctors who aren't so computer saavy, and they
won't accept that as a solution because it requires a couple extra clicks.

What also would work, and probably be more realistic, is if I could a text
box next to the drop down, and have the text box fill in with whatever is
selected in the drop down. Is that possible? Like an event where when you
select something in the drop down, it fills out the appropriate text box?

Sorry this is long; thanks in advance for any advice.

Mike
 
K

kill_beast

Sorry, I should have been more clear.

The application I mentioned purposely opens it in WordPad. That's just the
way the app was designed. You click an 'Edit' button, and it opens in Word
for editing, then when you click a 'View' button, it uses WordPad to show you
the document.

So what I'm looking for is how to get the form to save drop down information
as text so that WordPad can display (it just leaves whitespace where the drop
down would be).

Thanks. =)
 
G

Graham Mayor

You need a macro. The following will convert all the entered form data to
text then saves the resulting document. The only thing you then have to
worry about is getting the users to run the macro. A custom toolbar on the
form with a button to call the macro should work -
http://www.gmayor.com/installing_macro.htm or if you save the macro in the
form template, you could call the macro FileSave and it would run when the
user saves the form.

Sub FixFormFields()
Dim bProtected As Boolean
Dim oFld As FormFields
Dim sText As Variant
Set oFld = ActiveDocument.FormFields
'Unprotect the file
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If

While oFld.Count > 0 'while there are still form fields
'Select the first available form field
oFld(1).Select
'Gather the result
sText = oFld(1).Result
'Replace the field with the result
Selection.TypeText sText
Wend 'and go round again
ActiveDocument.Save 'then save the document
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
K

kill_beast

That worked perfectly.

Thanks!

Graham Mayor said:
You need a macro. The following will convert all the entered form data to
text then saves the resulting document. The only thing you then have to
worry about is getting the users to run the macro. A custom toolbar on the
form with a button to call the macro should work -
http://www.gmayor.com/installing_macro.htm or if you save the macro in the
form template, you could call the macro FileSave and it would run when the
user saves the form.

Sub FixFormFields()
Dim bProtected As Boolean
Dim oFld As FormFields
Dim sText As Variant
Set oFld = ActiveDocument.FormFields
'Unprotect the file
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If

While oFld.Count > 0 'while there are still form fields
'Select the first available form field
oFld(1).Select
'Gather the result
sText = oFld(1).Result
'Replace the field with the result
Selection.TypeText sText
Wend 'and go round again
ActiveDocument.Save 'then save the document
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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