Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a sheet that I do not want date selections applied to so I want to run a macro when the sheet opens to save the values in a variable and then clear the field selections. On exiting the sheet I want to take the values stored in the variables and update the field values again. I have the following for storing the values.
Sub SiteCompareNoDate
'Set variables to store the date selections.
set DtSelStart = ActiveDocument.Fields("Start Date").GetSelectedValues
set DtSelComp = ActiveDocument.Fields("Completed Date").GetSelectedValues
'Clear the date field selections.
ActiveDocument.Fields("Start Date").Clear
ActiveDocument.Fields("Completed Date").Clear
End Sub
Now I would like to create another macro that will reapply the values once I leave the sheet. How would I accomplish this?
Jake Kibler
I suggest to use actions which set a variable-value per getfieldselections() or concat() instead of use of macros. Here you will get some ideas: Tracking the historical selections.
- Marcus
Originally I was. I had sheet On Open triggers that were setting the variables (1 variable per field) then clearing the field selections. Then actions sheet on leave that would take the values in each of the variables and set the field value back.
It worked great when I was working on it locally, but when we deployed to our server which uses AJAX the sheet on open and on leave triggers do not work.
In this case macros won't help (rather the opposite especially within AJAX) because the issue is the trigger regardless if an action or a macro is behind them. But it's new for me that an ActivateSheet don't work (OnOpen is often difficult) maybe there is a conflict with multiple actions or with the QV release - which one is in use?
If this don't help you will need another kind of usability - maybe with alternate states like suggested from Marco or the disabling from the native sheet-navigation and replacing them with buttons/textboxes.
- Marcus