PDA

View Full Version : Find marked text and populate combobox



pnewton
06-04-2008, 03:53 PM
I have a templated document with text marked with leading and end characters, ie. ^Country:Australia,Japan,USA^

Effectively, what I am trying to achieve is to find the marked text, take the "Country:" part of the string (i.e. anything from the first "^" to the ":") and use that as the label text, and have the three countries listed in a combobox as a selection.

Once user selects the country from the drop down and hits the ok button, the original ^Country:Australia, Japan, USA^ is replaced with the country they selected

Any help greatly appreciated.

Pete

lucas
06-04-2008, 05:06 PM
Why not have the 3 countries in a combobox on a userform that opens when document new fires. Let them choose the country and put it in a bookmark named "country" in the new document?

pnewton
06-04-2008, 06:29 PM
Thought of that but looking to use script across differing documents with different variables depending on the document, want to be able to easily update variables without going into code, seems like most logical way if variables in document, not code. Do welcome more ideas.

lucas
06-04-2008, 07:44 PM
Post #1

I have a templated document
Post #3

Thought of that but looking to use script across differing documents

You can see why I might be confused.......

pnewton
06-04-2008, 07:46 PM
yes, sorry about that. plan is to reuse the code/forms on different templates, ie. each template has code/forms and can be used separately

lucas
06-04-2008, 07:54 PM
You could do this but it will take some work on your part. Look up find for a way to find the ^ Then you can count charactors using Len....look it up and then put the last part....the countries into an array to populate the combox. If you get started and have trouble you can post back here with specific questions and tips.

lucas
06-04-2008, 07:57 PM
yes, sorry about that. plan is to reuse the code/forms on different templates, ie. each template has code/forms and can be used separately

But if you're using templates then the selections are finite to that template......I guess I don't understand. :aw

pnewton
06-04-2008, 08:01 PM
I want them to be finite to the specific template. When i referred to "differing documents" i was referring to templates (with the code/form embedded in each, dependent on which templates required the functionality). Hope this clarifies my requirements

pnewton
06-04-2008, 08:29 PM
upon consideration, change of plan, think best to have a global template that enables this function (i.e. button on toolbar). Is it possible?

lucas
06-05-2008, 07:59 AM
yes, when you get your function ironed out.

Tinbendr
06-05-2008, 08:35 AM
But if you're using templates then the selections are finite to that template.....I'd have to agree with Lucus, you're not making much sense, but here is a sample doc that processes the string.

lucas
06-05-2008, 08:59 AM
That's a nice one Tin man......I was hoping the poster would start the project and not give a solution so they could learn from it but this should meet his/her need quite nicely. Now all he has to do is add it to a global template in the startup folder with a menu added like this (http://slucas.virtualave.net/Wink/CustomMenuItem.htm) and its ready to use on any document.

Tinbendr
06-05-2008, 10:20 AM
I was hoping the poster would start the project ...Yes, I could sense the gentle nudging. Sorry if I spoiled your objective.

The code could stand much improvement, so maybe he'll tackle the fine tuning.

lucas
06-05-2008, 10:54 AM
No problem......better to get more help than they really need....This should work nicely for the task at hand.

pnewton
06-09-2008, 01:49 PM
Hi guys

Thanks for all your help. I must admit I was struggling with this one ... truly an awesome help and thanks again.