View Full Version : from combobox to document
saban
01-25-2007, 09:05 AM
How the hell can I put Name that is selected in ComboBox into document
It must be very easy but I cant figure it out :(
lucas
01-25-2007, 10:01 AM
well...is it on a userform or on the page?
lucas
01-25-2007, 10:04 AM
does it go in a form on the page or to a bookmark?
lucas
01-25-2007, 10:16 AM
try this on a userfom:
Private Sub CommandButton1_Click()
Dim oBM As Word.Bookmarks
Set oBM = ActiveDocument.Bookmarks
'Bookmark name is Example 1
oBM("Example1").Range.Text = ComboBox1.Value
End Sub
saban
01-26-2007, 01:37 AM
Well it is on User form and the text from it should just be inserted in selection (or where cursor is) no big deal
thnx
lucas
01-26-2007, 07:44 AM
Something like this?
Selection.TypeText Text:=ComboBox1.Value
fumei
01-26-2007, 08:11 AM
Or if you are replacing the selection text....Selection.Text = Combobox1.Text
Or, if you are putting the Combobox text after the Selection....Selection.Range.InsertAfter Text:=ComboBox1.Text
As you do not state what you actually want to do, the answer is:
You can put the combobox text anywhere you want using either Selection.Text, Selection.Typetext, or the various properties of Selection.Range (InsertBefore, InsertAfter, Paragraphs.......and THEIR properties)
For example, you could have a paragraph, such as:
"This is a paragraph of such text and it really doesn't matter what the heck it is, as I am going to replace it with something else now."
And a combobox with three items:
"blah"
"who cares"
"what?"
Say you select "who cares" as the item, and run:
Selection.Range.Paragraphs(1).Range.Text = ComboBox1.TextThen - assuming the Selection is IN that paragraph - the paragraph text regardless of whether the selection covers the whole paragraph (or not), will become the combobox1.text.
That paragraph text will become "who cares".
All the properties of Selection (and its Range, AND the properties of the range) are available to you.
saban
01-29-2007, 03:15 AM
Thnx gary for detailed explanation on ComboBox
Stay cool
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.