View Single Post
 
Old 03-03-2023, 05:25 AM
shaunfish shaunfish is offline Windows 10 Office 2021
Banned
 
Join Date: Mar 2023
Posts: 1
shaunfish is on a distinguished road
Default Filling in legacy dropdown and using result to display information.

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
Reply With Quote