eazyt33
12-02-2022, 08:52 AM
Hello,
I have programmed in VBA for years but mostly in Excel. Right now, I am making a .DOTX or template file in Word and I have a Drop-Down List (content control style) and I am attempting to give users the ability to select items from the list and have the selections populate to preselected locations in the Word Document. Does that make sense?
My main issue is that I have no working knowledge of the vba behind these "content controls" I just spent hours reading through literature about them but can't quite wrap my head around it. Below is my really bad attempt at what I am trying but should shed some light on where I am going with this. Basically, I would like the user to "activate" the drop down, click the item them want, and it will populate directly below (using a bookmark) in the word document. If they select another item, it will in some way populate with the first item or move on to the next line below the first entry.
I know this is not great but I think it will guide a better understanding of what I am trying to accomplish. Hopefully it is possible and thanks in advance.
Sub DDmulti()
Dim doc As Word.Document
Dim ccLB As Word.ContentControl
Set doc = ActiveDocument
Set ccLB = doc.SelectContentControlsByTitle("lb").Item(1)
If ccLB.selected Then
Selection.GoTo What:=wdGoToBookmark, Name:="lb"
With Selection
Selection.Add
End With
End If
End Sub
I have programmed in VBA for years but mostly in Excel. Right now, I am making a .DOTX or template file in Word and I have a Drop-Down List (content control style) and I am attempting to give users the ability to select items from the list and have the selections populate to preselected locations in the Word Document. Does that make sense?
My main issue is that I have no working knowledge of the vba behind these "content controls" I just spent hours reading through literature about them but can't quite wrap my head around it. Below is my really bad attempt at what I am trying but should shed some light on where I am going with this. Basically, I would like the user to "activate" the drop down, click the item them want, and it will populate directly below (using a bookmark) in the word document. If they select another item, it will in some way populate with the first item or move on to the next line below the first entry.
I know this is not great but I think it will guide a better understanding of what I am trying to accomplish. Hopefully it is possible and thanks in advance.
Sub DDmulti()
Dim doc As Word.Document
Dim ccLB As Word.ContentControl
Set doc = ActiveDocument
Set ccLB = doc.SelectContentControlsByTitle("lb").Item(1)
If ccLB.selected Then
Selection.GoTo What:=wdGoToBookmark, Name:="lb"
With Selection
Selection.Add
End With
End If
End Sub