Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scripting in Outlook ... losing variables...

Status
Not open for further replies.

PerlIsGood

Programmer
Jan 24, 2002
154
US
Well, not losing, but not being recognized. The following bit of code was written for a custom form in Outlook and has worked flawlessly since I put it together. Just today I decided to move all of the Set [VAR] statements to their own sub() to cut down on script size (there were near 30 for each function).

Now, around 80-85% of these same variables are being recognized, while the others simply are not, or I get an error saying that the variable is not a valid object...

Specific Example:
Code:
Call SetVars() 'way earlier in the function...placed here for example...
If txtCandEmail1.Value > "" And txtCandEmail2.Value > "" Then
    i.Recipients.Add txtCandEmail1
    i.Recipients.Add txtCandEmail2
    i.Recipients.Add txtGreeter
    i.Display
ElseIf txtCandEmail1.Value > "" And txtCandEmail2.Value = "" Then
    i.Recipients.Add txtCandEmail1
    i.Recipients.Add txtGreeter
    i.Display
ElseIf txtCandEmail2.Value > "" And txtCandEmail1.Value = "" Then
    i.Recipients.Add txtCandEmail2
    i.Recipients.Add txtGreeter
    i.Display
Else
    MsgBox ("msg text..."), , "No Email on File"
End If
With this I get the error "Object required: txtCandEmail1". But then I have the Set txtCandEmail1 value in the SetVar() sub and it's set correctly (triple checked, twice). Not to mention that this same function is pulling and successfully using other variables from the sub().

I'm confused... There are two other functions exhibiting this same behavior with different variables. Anyone have any ideas why it would not be recognizing certain vars..?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top