Office Word Programming >> Advice wanted - choosing values from one array based on another

by paul_moloney » Wed, 25 Feb 2004 00:43:23 GMT

Currently, I have a template which stores an array of
product codes, and allows you to select these in a dialog box
and populate a document custom property with the selected
code:

productCodes = Array("SD", "PP", "TU", "RC", "AG", "AV")

[...]

UserForm1.ProductCode.List() = productCodes

[...]

.CustomDocumentProperties("ProductCode").Value = ProductCode.Value

I've also set up an array of the related product names:

productNames = Array("Service Delivery Platform", "PaymentsPlus",
"MobileTop-Up", "RC", "AG", "AV")

What I _want_ to do is to populate a custom document property
ProductName with the relevant product name, based on the product code
selected. How do I do this? Do I set up a two-dimensional array of
product names and product codes?
Or can I return the position in the productCodes array of the selected
product code (for example, SD is at position 0) and return the
variable in productNames at the same position? I'm afraid my VBA
knowledge doesn't come up to scratch here. Any help is appreciated,

P.


Similar Threads

1. Advice wanted - choosing values from one array based on another - Word VBA

2. want word to choose a defined paragraph based on a value in merge

I would like to have a single word merge document but have a paragraph in the 
letter change based on a value in a merge file. For example, the customer has 
a credit rating of 1, he gets a nasty paragraph. If he has a 5 in the field 
he gets the nice paragraph. It is the Word document that chooses which 
paragraph to use will base it's decision on a predefined criteria. eg if 
<<credref>> >3 then nice else nasty.
I am creating the merge file from a CIS system which determines the credit 
value but I want word to choose the appropriate paragraph. I hear it can be 
done but can't find it in help.

3. Choosing one of several arrays? - Word VBA

4. Populate one field based on value of another

Here's my question...

I want to populate Field2 based on the vaule in Field1.  Field1 is a 
dropdown box.  If I select a specific value from that box, I want a macro to 
detect the value and populate Field2, a text field.

I can't seem to find the right command in VB.  Any help?!

thx!

5. Postfix / Prefix Operators on array / pointer, search key word wanted [OT]

6. Postfix / Prefix Operators on array / pointer, search key word wanted [OT]

By searching with following key word in google clc and google's WWW 
archives:
     1) Pointer arithmetic
     2) Pointer subtraction
    
   I get some links for the question in subject line.
  
   Bitwise operator is a constrain. So I need not search
   about it.

     3)Postfix operators (on/and) array
         By the above key word is failed to return any pointers
   
     4)operators and array
         Some results
 
     5)array subtraction
         Finds no results

     6)pointer subtraction
         Throws some results

  Can Any body help me with the ideas for more proper key words for
  the subject (i.e. Arrays and C operators) to search both clc and 
google's WWW
  for links?

   Thanks
 

-- 
"Combination is the heart of chess"
		        A.Alekhine
Mail to:
  sathyashrayan25 AT yahoo DOT com
  (AT = @ and DOT = .)

7. VBA Sort 2-dimensional array based on 2 column

8. Conditional Format - Array based on cell in column

How do you apply a conditional format based on a cell in single column and 
apply it across multiple columns?

Example:
             A          B        C       D
ROW1    Critical
ROW2    High
ROW3    Critical

Conditional Format - if text in column "A" = "Critical" format all text 
color red in columns A - D.  Thanks.