![]() |
#1
|
|||
|
|||
![]()
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.
Nothing seems to happen unless I click on the textbox and then I get an error saying that my text is too long. However the textbox is set to unlimited size Here is a copy of my code Option Explicit Dim info As String Sub sinor() ' ' test Macro ' ' Documents.Open FileName:="C:\Users\Shaun\Desktop\lollz\descriptio ns.docx" Selection.GoTo What:=wdGoToBookmark, Name:="SinoR" Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Copy ActiveWindow.Close info = Selection '.PasteAndFormat(wdFormatOriginalFormatting) End Sub Sub kamir() Documents.Open FileName:="C:\Users\Shaun\Desktop\lollz\descriptio ns.docx" Selection.GoTo What:=wdGoToBookmark, Name:="KamiR" Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Copy ActiveWindow.Close info = Selection '.PasteAndFormat(wdFormatOriginalFormatting) End Sub Sub fetch() Dim myform As Document Set myform = ActiveDocument Dim bProtected As Boolean 'Unprotect the file If ActiveDocument.ProtectionType <> wdNoProtection Then bProtected = True ActiveDocument.Unprotect Password:="" End If Select Case ThisDocument.FormFields("code").Result Case "Item 1" sinor ThisDocument.FormFields("Text1").Result = info Case "Item 2" kamir ThisDocument.FormFields("Text1").Result = info End Select If bProtected = True Then ActiveDocument.Protect _ Type:=wdAllowOnlyFormFields, _ NoReset:=True, _ Password:="" End If End Sub I have been busy on this for 3 days now and it has become urgent. Any help would be greatly appreciated Regards Shaun |
#2
|
|||
|
|||
![]()
A combobox is not available as a formfield. There is a ComboBox Content Control.
You could put a combobox in a UserForm but that is not in the document. Legacy formfields and Content Controls should not be used in the same document.I I do not see any reason for a combobox here. I am moving this to the vba forum. |
#3
|
|||
|
|||
![]()
Hi Shaun,
I moved this to the Word vba forum and retitled it. Please feel free to edit the title if I got it wrong. What I used is: Filling in legacy dropdown and using result to display information. I think you would be better off with a UserForm, myself. Does this need to be in a document protected for filling in forms? |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
bil_san1 | Word | 3 | 10-14-2022 08:59 AM |
![]() |
philip.anthony | Word VBA | 11 | 03-28-2022 02:15 PM |
Display Formula in Once Cell, Result in Another | rspiet | Excel | 5 | 06-05-2018 08:27 AM |
![]() |
timomaha | Excel | 1 | 09-12-2014 07:51 AM |
Filling in legacy field causes rest of line to move to next tab stop | rtrdom | Word | 5 | 12-14-2013 05:48 PM |