Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
camilo
Contributor III
Contributor III

Macro - Select all but

Hi,

I´m Trying to make a macro that selects everything except one tipe of field.

Right now I know if I want to select that one field I have to use:

Sub Reempaque
ActiveDocument.Fields("Variedad").Clear
ActiveDocument.Fields("Variedad").Select("Reempaque")
end sub

But I want to select all the other fields but "Reempaque" what do I have to use?

Thanks,

1 Solution

Accepted Solutions
disqr_rm
Partner - Specialist III
Partner - Specialist III

Sub AllOtherThenReempaque
ActiveDocument.Fields("Variedad").Clear
ActiveDocument.Fields("Variedad").Select("Reempaque")
ActiveDocument.Fields("Variedad").SelectExcluded

end sub

View solution in original post

4 Replies
Not applicable

You can use ToggleSelect to unselect a selected value.

So if you use:

Sub Reempaque
ActiveDocument.Fields("Variedad").SelectAll
ActiveDocument.Fields("Variedad").ToggleSelect("Reempaque")
end sub


disqr_rm
Partner - Specialist III
Partner - Specialist III

Sub AllOtherThenReempaque
ActiveDocument.Fields("Variedad").Clear
ActiveDocument.Fields("Variedad").Select("Reempaque")
ActiveDocument.Fields("Variedad").SelectExcluded

end sub

camilo
Contributor III
Contributor III
Author

Thanks very much Rakesh and Nmiller, I tried the SelectExcluded option and it does work perfectly!

Not applicable

I tried just this below to create a macro. This selects all items in a the field. However I want to be able to just pick 1 item, any item in that field. However I cannot name a specific one because that will always be different. Any ideas on how to just get it to pick one, maybe the first in the list?



function

{

ActiveDocument.Fields(

"ResidentName").ToggleSelect("*")

}





Select()