![]() |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
![]()
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 |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
marksm33 | Word VBA | 3 | 01-15-2015 07:55 PM |
![]() |
supremegrandruler | Word | 1 | 12-09-2014 03:17 PM |
![]() |
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 |