Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello, I have written a macro as below for 2 modules: Clear Rebates and Reset Exchange Rates which clear the input field named 'Rebate' and reset the values of the input field 'FX_Rate' respectively.
Sub ClearRebates
set fld = ActiveDocument.Fields("Rebate")
fld.ResetInputFieldValues 0
End Sub
sub ResetExchangeRate
dim x(1)
x(0) = 0 ' element to reset
set fld = ActiveDocument.Fields("FX_Rate")
fld.ResetInputFieldValues 0, x ' 0 = All values reset, 1 = Reset Possible value, 2 = Reset single value
end sub
However, when I add this Run Macro action to a button, the macro isn't running but the Edit Module button keeps popping up. I read in a different thread that this happens in the macro is wrongly written. As I'm pretty new to macros and only got the above code from this wonderful community, I'm not able to understand what's wrong with the macro. Please help me out! TIA!
Phalgun,
Have a look at the attached file. It is working fine for me. You don't need to share your original file but you can create a sample file like I provided and show us your issue.
Hi Phalgun,
I am not sure what you are trying to achieve but try this. If this is not your question, please post a sample and expected result.
Sub ResetExchangeRate
set fld = ActiveDocument.Fields("FX_Rate")
fld.ResetInputFieldValues 0, 0 ' 0 = All values reset, 1 = Reset Possible value, 2 = Reset single value
End sub
Hi Tamil,
The ClearRebates module is used to reset the values of the inputfield named 'Rebate' to 0. The ResetExchangeRate module is used to reset the values of an inputfield which contains currency exchange rates to their original values when loaded from an excel file. Hope that helps as I cannot share the file unfortunately. And I'm using these macros as an action in two different text objects as triggers. But when I click the object, the Edit Module box pops up instead of macro running.
Phalgun,
Have a look at the attached file. It is working fine for me. You don't need to share your original file but you can create a sample file like I provided and show us your issue.
Hi,
Thanks for your time. It looks like it's some weird glitch as the macros started working fine after I closed and reopened the file. Don't know why.