Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Retrieve field value to Macro

Hi Guys,

I have a table field named FullName.

How do I retrieve the value ( only 1 already selected value from the field) to a variable in a macro?

Something like:

Dim Name

Name = ActiveDocument.Field(FullName).GetContent().String

Thanks in advance,

Aldo.



1 Solution

Accepted Solutions
Not applicable
Author

I'm lazy, so usually, I'll make a variable that is equal to:

=GetFieldSelections(FullName) or =ONLY(FullName)


And then in my macro use:

Name = ActiveDocument.Variables(vName).GetContent.String


If you only have one selection, you can do it without the variable using:

set doc = ActiveDocument
set mySelections = doc.fields("Field").GetSelectedValues
mySelections.Item(0).text


If you have more than one selection, then you have to loop through the item array.

View solution in original post

2 Replies
Not applicable
Author

I'm lazy, so usually, I'll make a variable that is equal to:

=GetFieldSelections(FullName) or =ONLY(FullName)


And then in my macro use:

Name = ActiveDocument.Variables(vName).GetContent.String


If you only have one selection, you can do it without the variable using:

set doc = ActiveDocument
set mySelections = doc.fields("Field").GetSelectedValues
mySelections.Item(0).text


If you have more than one selection, then you have to loop through the item array.

Not applicable
Author

Thanks man, I did it as you with the variable.

Aldo.