Select Case with Dropdown

L

Lenny

Am developing a Word 2003 protected template. Scenario: the template is a
business card request form. When the user selects their facility from a
dropdown in one of the form fields, I would like to populate a 'dummy' of the
card I have created with the 'plant name' and below that, the three line
plant address.

Using the select case works very well, but was wondering whether there was a
way I could break the plant information into the requisite number of lines?
Is there a different or better way to accomplish the same? See example...

Example:
Sub FillInAddress()
Dim oDoc As Document
Dim sigName As String
Set oDoc = ActiveDocument
sigName = oDoc.FormFields("Dropdown1").Result
Select Case sigName
Case "Plant 1"
oDoc.FormFields("Text1").Result = "Name of Facility, Street Address -
City, State, Zip Code USA"

This prints out in 1-line but need to have it replicated in the dummy form as:

Name of Facility
Street Address
City, State, Zip Code USA
 
D

Doug Robbins - Word MVP

Create an autotext entry for each of the required addresses, then use the
following:

' Macro created 15-11-97 by Doug Robbins to add the address corresponding to
a drop down name
'
Set myDrop = ActiveDocument.FormFields("Dropdown1").DropDown
Company = myDrop.ListEntries(myDrop.Value).Name
Address = ActiveDocument.AttachedTemplate.AutoTextEntries(Company).Value
ActiveDocument.FormFields("Text1").Result = Address

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
L

Lenny

Doug - a problem:
The 'autotext' entry formatting that was created disappears in the 'text1'
field. The font is correct, but other attributes like bolding, line spacing
and kerning are not brought in. Is there a way to maintain integrity of the
autotext formatting? If not using set myDrop, is there a different way to
achieve the same without losing the autotext formatting....please reply

Lenny
 
D

Doug Robbins - Word MVP

Try just having a bookmark in the document where you want the information to
appear and then use

Set myDrop = ActiveDocument.FormFields("Dropdown1").DropDown
Company = myDrop.ListEntries(myDrop.Value).Name
Address = ActiveDocument.AttachedTemplate.AutoTextEntries(Company).Value
With ActiveDocument
.Unprotect
.Bookmarks("Bookmarkname").Range.FormattedText = Address
.Protect wdAllowOnlyFormFields, NoReset
End With





--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
L

Lenny

Doug - my thanks for getting back. Just about the time I hit the send
button, I remembered that the 'form' field cannot contain multiple formats
(i.e., bold type AND regular) even though the autotext entry was formatted
that way....best regards
Lenny
 

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