Thanks for the help. I get a little confused on functions.
I am now getting -- Object required: 'ActiveDocument.Variables(...)'
when I click the test button in the module editor and the email does not get sent when I run the load script.
In the load script I have
I am amusing this is the magic that creates the variable that can be used in the macro by taking the value of the contract field? Contract is a field in the table. Is it correct to say that vSubject should now be in memory?
You can see the contents of any variable in Settings > Variable Overview.
If the variable is null or has strange characters, that could be the reason why it's not working. You can also use the Set in the script for a fixed text, instead of a variable, to see whether it works.
EDIT: on a second read, two thoughts:
No, any ActiveDocument property does not exist when reloading the script, for this the document needs to be open after a reload
It could be a typo but the names of the variables are different in the script (vEmailSubject) and in the macro (vSubject)
Am I on the right track in the load script with? --
Will this do what it takes to make it available to a Macro/function called from my load script?
I do not see vSubject in Settings>Variable Overview.
So I cannot use ActiveDocument because it is not available until after the reload is done? Does this mean that all lines be interpreted and you are back to the document OR from LOAD to ; since there can be multiple loads?
How do I make the value available when I am running the macro?
Here is what I need to do. I have it all working except for the subject field.
1. Load script loads from a SQL query. The results show only the records where the 'Contract' due date is current. There might be 0, 1 or many contracts due.
2. The FOR NEXT loop will handle each record (Contract) and send an email to the specific person that needs to act on it.
3. A Function/Macro will be used to send that email.
I have everything working except for being able to use variables in the Subject, Body or Address. If it helps I can supply the simplified code with an in line table. This will take a little time and I wanted to get back as soon as possible.
Thank you for getting me back on track. I did start by trying to do it that way but had my syntax off.
In my FOR/NEXT loop I was using FORi=1to$(NumRows) When I should have been using i=0 as PEEK starts at zero. Below I have included enough of the Load and Macro to get someone else started if they want to send separate emails to multiple people.
I have seen a lot of negative opinions on using macros but could not make it work any other way.I did start by trying to use the Alerts. I was not able to get it to send to multiple people each with its specific Contract number. If anyone sees this and wants to enlighten me I would appreciate it.