Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2007

Tip: Looking for answers? Try searching our database.

Select Case with Dropdown

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lenny - 14 Aug 2007 23:46 GMT
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
Doug Robbins - Word MVP - 15 Aug 2007 01:28 GMT
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

Signature

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

> Am developing a Word 2003 protected template.  Scenario:  the template is
> a
[quoted text clipped - 27 lines]
> Street Address
> City, State, Zip Code USA
Lenny - 15 Aug 2007 18:50 GMT
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

> Create an autotext entry for each of the required addresses, then use the
> following:
[quoted text clipped - 38 lines]
> > Street Address
> > City, State, Zip Code USA
Doug Robbins - Word MVP - 16 Aug 2007 10:43 GMT
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

Signature

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

> Doug - a problem:
> The 'autotext' entry formatting that was created disappears in the 'text1'
[quoted text clipped - 57 lines]
>> > Street Address
>> > City, State, Zip Code USA
Lenny - 17 Aug 2007 01:48 GMT
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

> Try just having a bookmark in the document where you want the information to
> appear and then use
[quoted text clipped - 69 lines]
> >> > Street Address
> >> > City, State, Zip Code USA
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.