R
ryguy7272
From Word’s help menu, I can tell that the BoundColumn identifies the column
of associated data values stored for the control. There doesn’t seem to be a
whole lot of documentation on this subject, but I am pretty sure it does what
I want it to do.
Thanks to some slick code provided by Doug Robbins, I can get data from an
Excel workbook to populate my ListBox, but I can’t seem to get the code form
the ListBox into my Word document.
The code that I am currently working with is shown below:
Sub CommandButton1_Click()
Set NewDoc = ActiveDocument
With NewDoc
cmbFirstName.BoundColumn = 1
.Variables("varFirstName") = cmbFirstName.Value
End With
UserForm1.Hide
End Sub
Private Sub Click()
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"DOCVARIABLE FirstName ", PreserveFormatting:=True
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"DOCVARIABLE LastName ", PreserveFormatting:=True
End Sub
In my word document, I have several fields such as this:
Error! No document variable supplied.
Error! No document variable supplied.
I keep getting this message when I hit Ctrl+F9:
Error! No Document variable Supplied.
What am I doing wrong?
Cordially,
Ryan---
of associated data values stored for the control. There doesn’t seem to be a
whole lot of documentation on this subject, but I am pretty sure it does what
I want it to do.
Thanks to some slick code provided by Doug Robbins, I can get data from an
Excel workbook to populate my ListBox, but I can’t seem to get the code form
the ListBox into my Word document.
The code that I am currently working with is shown below:
Sub CommandButton1_Click()
Set NewDoc = ActiveDocument
With NewDoc
cmbFirstName.BoundColumn = 1
.Variables("varFirstName") = cmbFirstName.Value
End With
UserForm1.Hide
End Sub
Private Sub Click()
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"DOCVARIABLE FirstName ", PreserveFormatting:=True
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"DOCVARIABLE LastName ", PreserveFormatting:=True
End Sub
In my word document, I have several fields such as this:
Error! No document variable supplied.
Error! No document variable supplied.
I keep getting this message when I hit Ctrl+F9:
Error! No Document variable Supplied.
What am I doing wrong?
Cordially,
Ryan---