Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
jduenyas
Specialist
Specialist

Sheet trigger


Hi all

I have an OnActivateSheet trigger which is comprised of 2 actions.

First Action is "Clear All" which works OK.

2nd Action calls for a Run Macro.

The code behind the macro (VBScript) is simple. Here it is:

Sub SelectCurrentYear()

       ActiveDocument.Fields("YR").Select Year(now())

End sub

When running the macro from the Edit Module it performs correctly however does not run from the trigger.

(The same macro is being called from various buttons and performs correctly when they are pressed.)

Any idea why?

Thanks

Josh

5 Replies
Not applicable

Hello,

Why are you using a macro ?

You can use the action : 'Select in field' with YR = Year(now())

action.png

jduenyas
Specialist
Specialist
Author

Thank you Blond

Actually my example was simplified and was to bring a point that a Macro is not triggered in OnActivateSheet.

The actual actionthat I use invokes a macro that selects the last 12 (or 24 or 36) running consecutive months.

I am not sure that this can be achived using Select in Field. (If it is possible, I would like to know how)

I have a VB function, that based on a parameter (12, 24 or 36) selects the number months. But as mentioned it does not work from the trigger but does work when run manuall or from a button.

Not applicable

Hi,


I hope the qvw attached will help you.


I create a key field in my calendar which is Year*12 + Month, i also created a variable containing the number of running consecutive months to select.

The trigger i created is then based on this field. I didn't use any macros.

jduenyas
Specialist
Specialist
Author

merci beaucoup Blond

francoiscave
Partner - Creator III
Partner - Creator III

Merci beaucoup Marie-Sophie 😉