Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
i have two questions for macro for default selections.
1.How to apply a macro to select all values in a particular list box.
2. How to apply a macro to select all values except one in a particular list box.
Can anyone help me out with code here.
Khushboo
Then you should tell the client that it's a bad solution. Actions are better.
However, the following macro will select all values:
Sub SelectX
ActiveDocument.Fields("Month").Select "*"
End Sub
The following macro will select all except September
Sub SelectY
ActiveDocument.Fields("Month").Select "September"
ActiveDocument.Fields("Month").SelectExcluded
End Sub
HIC
No, you should not use a macro for this. Macros often don't work in a server environment. See Macros are Bad.
What you can do instead, is to use an Action. If you want to select all but one value in a field you can do this by first selecting the value to exclude, then "Select Excluded".
HIC
Thanks Henric.
But client wants us to use macro only so cant help it.
If you have to use Macros then this gives you some simple examples:
1)
Sub SelectAll
ActiveDocument.Fields("Month").Select "*"
End Sub
2)
Sub SelectAllButOne
ActiveDocument.Fields("Month").Select "September"
ActiveDocument.Fields("Month").SelectExcluded
End Sub
Then you should tell the client that it's a bad solution. Actions are better.
However, the following macro will select all values:
Sub SelectX
ActiveDocument.Fields("Month").Select "*"
End Sub
The following macro will select all except September
Sub SelectY
ActiveDocument.Fields("Month").Select "September"
ActiveDocument.Fields("Month").SelectExcluded
End Sub
HIC
Thank You everyone