PDA

View Full Version : selected item in listbox to document



saban
01-25-2007, 02:09 AM
Hi guys I need a little help

In ListBox I have records which are taken from some doc document and when user selects one of them and presses OK button I would like to have them in document-Active one

In short how do I put selected item in listbox to word document

Thnx

Bob Phillips
01-25-2007, 02:12 AM
Depends where you want to store, but you could create a bookmark, and store it there.



Dim rng As Range
If ActiveDocument.Bookmarks.Exists(bookmark) Then
Set rng = ActiveDocument.Bookmarks(bookmark).Range
rng.Text = Listbox1.Value
ActiveDocument.Bookmarks.Add bookmark, rng
Else
MsgBox "Bookmark " & bookmark & " not found."
End If
Set rng = Nothing

saban
01-25-2007, 02:42 AM
thnx

I have one more question:
How can I alphabetically oreder a list in list box and when i press for instance key a item starting with letter a is selected in list box

Thnx again for all your help

Bob Phillips
01-25-2007, 03:10 AM
You would need to extract all the items into an array, and sort the array, then load back in (could do it direct I guess).

Listbox doesn't support that functionality, but Combobox does.

saban
01-25-2007, 03:24 AM
Cool Thnx