Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Word combobox question

Word combobox question

Word combobox question

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?



RE: Word combobox question

Hi Shaun,

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

This is just a guess, but this is what I imagine in your document one:

Item     Definition
Item A   This is Item A's definition
Item B   Some description on this Item
         goes here
Item X   Another definition that applies
         to Item X that needs to be displayed
         in another document
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

Hi all
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.


RE: Word combobox question

>I tried using text field

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

Strongm has the correct approach.

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

>Word VBA and Excel VBA are different in a lot of ways

Point of prder: Excel VBA and Word VBA are the same. It is the host applications' object models that differ.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close