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

Reset input box using macro on Clear All button

Hi - I'm trying out a macro I found on this discussion board, but it's not working for me. I have an Input Box with 5 predefined values. I need the input box to reset or clear (show no values) when the user clicks the Clear All button.  I've added the following macro as an Action on the Clear All button. It does clear the value in the Input Box, but the Edit Module box keeps opening everytime it runs. I'm not sure what is wrong with the macro. Any suggestions will be appreciated! Thanks--Cat

sub IBclear

'Clear All input boxes

  set ClearAllib = ActiveDocument.GetSheetObject("IB10")

  ClearAllib.SetVariableContent 0,"",true

  ClearAllib.SetVariableContent 1,"",true

  ClearAllib.SetVariableContent 2,"",true

  ClearAllib.SetVariableContent 3,"",true

  ClearAllib.SetVariableContent 4,"",true

'  ActiveDocument.ClearAll false

end sub

1 Solution

Accepted Solutions
CELAMBARASAN
Partner - Champion
Partner - Champion

Check with this macro

sub clear

set v = ActiveDocument.Variables("Variable1")

prop = v.GetProperties

dim list

list=Array("abc","45","xyz","")

prop.PreDefinedList = list

v.SetProperties prop

set ClearAllib = ActiveDocument.GetSheetObject("IB10")

ClearAllib.SetVariableContent 0,"",true

Erase list

list=Array("abc","45","xyz")

prop.PreDefinedList = list

v.SetProperties prop

end sub

View solution in original post

8 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

To set an empty value for the input box with option predefined values only. you have to include emtpy value in the predefined values. simply semicolon without any chars

Example: ;1;2;3;4;5

Not applicable
Author

Thanks. That is my workaround, however it puts a blank line in my dropdown. I'd like to use a macro to avoid having this extra blank line.

CELAMBARASAN
Partner - Champion
Partner - Champion

You can go with other option as set any one as default value from the predefined values?

Not applicable
Author

No, there is no default value.

MayilVahanan

HI

Are you want something like attached file..

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
CELAMBARASAN
Partner - Champion
Partner - Champion

Check with this macro

sub clear

set v = ActiveDocument.Variables("Variable1")

prop = v.GetProperties

dim list

list=Array("abc","45","xyz","")

prop.PreDefinedList = list

v.SetProperties prop

set ClearAllib = ActiveDocument.GetSheetObject("IB10")

ClearAllib.SetVariableContent 0,"",true

Erase list

list=Array("abc","45","xyz")

prop.PreDefinedList = list

v.SetProperties prop

end sub

Not applicable
Author

Thank you! This works perfectly.

stevelord
Specialist
Specialist

Quick question, how would I modify this macro to work with input boxes that don't have predefined variables?  Just to wipe whatever they happen to have in them.  (Sorry I can't chip you points from this string, but level 10 says you're okay unless you're trying to dethrone Gysbert. )