Word combobox question
Word combobox question
(OP)
I have two word documents, one is a list of item definitions and the other is a form. I need to create a combo box on the form with a list of items, when an item is selected, I need for the definition to be displayed on the form. How do I link the two documents? Is it even possible?
Regards
Shaun
Regards
Shaun
RE: Word combobox question
It is possible to do what you are asking for. Do the two documents need to be Word? Can you use Excel instead?
The reason that I am asking is that performing the task in Word is 10x harder.
One thing to keep in mind is that Word VBA and Excel VBA are different in a lot of ways. Word VBA is a major pain compared to Excel VBA sit it is very rarely used.
The amount of time researching the Word equivalent of Excel VBA will be significant. Also, I've never met another person that can program Word VBA. This means that if you win the lottery, who can maintain and update the files?
RE: Word combobox question
I am with remeng, Word is a bad choice, but even Excel has its limits of how much text you can fit into one cell. If your Definitions are long, Excel may not be a good choice, either.
---- Andy
"Hmm...they have the internet on computers now"--Homer Simpson
RE: Word combobox question
Unfortunately is does have to be in word. The definitions are quite long, as in a paragraph of text. I suppose I could hard code the paragraphs but really don't want to do this. One think with with vba it would be a relative simple task.
I have managed to get vba to read in the definitions but now the trick is to paste it to the correct place in the report doc. I tried using text field but for some reason only a few words are displayed even after telling word that there is now word limit to the text field.
Regards
Shaun
RE: Word combobox question
Why not try using a bookmark? And then something like the following:
CODE -->
Public Sub example() InsertTextInBookmark "Insertionpoint", "Just some simple text" End Sub Sub InsertTextInBookmark(strBookmark As String, strText As String) Dim oRng As Word.Range Set oRng = ActiveDocument.Bookmarks(strBookmark).Range oRng.Text = strText ' overwrites bookmark ' reset bookmark ActiveDocument.Bookmarks.Add strBookmark, oRng End Sub
RE: Word combobox question
You'll need bookmarks, custom style, and tables to get the result that you are looking for.
The bookmark will allow you to define the location in the word document, the Style will allow you to correctly format the information from one word doc to another, and the table will create a default location for the text / paragraph to go.
With the table, you can assign it a name and use the index to define the cell location to paste to. After you test the macros and are happy with it, you can either leave the border showing or set it to white to hide it. NOTE: tables in Word do not have the same VBA code or formatting as Excel.
here is a thread I created about showing and hiding bookmarks. It might give you a little insight into how they can work Link
here is a link to vba with word tables: Link
Another good resource: Link
Coding tables: Link
Give those a quick look. I think those are good research starting points.
RE: Word combobox question
Point of prder: Excel VBA and Word VBA are the same. It is the host applications' object models that differ.