Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-28-2015, 06:59 AM
Attila Attila is offline Selected items in Combobox remain the same when closing and reopen document Windows XP Selected items in Combobox remain the same when closing and reopen document Office 2010 64bit
Novice
Selected items in Combobox remain the same when closing and reopen document
 
Join Date: Jan 2015
Posts: 7
Attila is on a distinguished road
Default Selected items in Combobox remain the same when closing and reopen document

Hello there..



I am not a programmer but like to program a small project with vba.

I have a Userform1 which contains a ComboBox1.
When I now select a value in the combobox in my userform it fills the value to the variable in my word document.
When I now hide the form with "Hide Me" it hides the userform and when I then reopen the userform with the Button in the word document all the previously selected items and entered textes in textboxes remain the same. So far so good.
But when I save the document close it and reopen it again all the values selected are on default again. I would like that the selected items and textboxes are the same as I entered the first time. So I may only change a little piece and not enter the hole info again.

I thought about adding a new list entry in my combobox with values from the variable so I can choose between the default entries and the now entered value. So I could then initialize my ComboBox with this list number.

Here is my code
The text in red is what i would like to do but doesn't work


Private Sub UserForm_Initialize()

ComboBox1.ColumnCount = 2
ComboBox1.ColumnWidths = "50;20"
Dim listEntries1(3, 1) As Variant
listEntries1(0, 0) = "This"
listEntries1(0, 1) = 1
listEntries1(1, 0) = "is"
listEntries1(1, 1) = 2
listEntries1(2, 0) = "a"
listEntries1(2, 1) = 3
listEntries1(3, 0) = "Test"
listEntries1(3, 1) = 4

'listEntries1(4, 0) = ActiveDocument.Variables.Item(var1).Value
'listEntires1(4, 1) = ActiveDocument.Variables.Item(var1).Value

Me.ComboBox1.List = listEntries1

With ComboBox1
ComboBox1 = ComboBox1.List(0)
End With

End Sub

Private Sub OK_Click()

'Define the variable oVars
Set ovars = ActiveDocument.Variables
'Assign the values of the text boxes to the variables
ovars("var1").Value = Me.ComboBox1.Value
ActiveDocument.Fields.Update

Unload Me

End Sub


I searched all over the internet for a solution but didn't find one.
So please can you help?
If you can help me with a better solution that the previously selected items remain selected so please tell me.

Thank you
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Selected items in Combobox remain the same when closing and reopen document Moving Selected Items from a Multiselect Listbox on a userform to a bookmark in Word marksm33 Word VBA 3 01-15-2015 07:55 PM
Selected items in Combobox remain the same when closing and reopen document How can I style individual items of a drop down or combobox? supremegrandruler Word 1 12-09-2014 03:17 PM
Selected items in Combobox remain the same when closing and reopen document Table in Mailmerge from selected items in access cnaab Mail Merge 1 11-01-2014 12:45 AM
Closing space between document and vertical ruler ToddPr Word 6 08-28-2014 12:12 PM
Word loses image sizing when I reopen file rbz1949 Drawing and Graphics 4 06-24-2010 11:19 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:30 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft