Expand|Select|Wrap|Line Numbers
- #If OutlookEnabled Then
- Dim olApp As Outlook.Application
- Dim olNewMaiItem As MailItem
- Set olApp = CreateObject("OutLook.Application")
- MsgBox "olApp created - Version = " & olApp.Version
- #Else
- MsgBox "Outlook not enabled"
- #End If
The boolean "OutlookEnabled" is not defined or set anywhere in the module, but it does seem to have a value. At least, if I change its spelling and run the routine, I get the message box saying "Outlook not enabled", so it looks like it somehow gets the value True.
Now, of course, I would expect that OutlookEnabled would really depend on the status outside of Access so I'm not really surprised that it's not set by VBA within Access. The question is where? Pressing F2 gives me the Object Browser, where I can select the Outlook library, for example and browse around for useful objects and properties so that I can refer, e.g. to:
olApp.Version
But OutlookEnabled does not seem to be among the properties (including globals) that I can find there. So where does it come from?
The other obvious quesion I have about the quoted code snippet is: what's up with the "#If" The hash symbol does appear to be meaningful and necessary. But in my admittedly limited library, the "#If" construction is supposed to be stuff that is conditionally compiled, e.g, for debugging, which would lead me to expect that without the #s the whole If-Then-Else-EndIf would be compiled and used all the time. However, if I remove the #s then I get the "Outlook not enabled" message instead of the version message.
In sum, it appears that there is a (system-wide?) variable OutlookEnabled that can only be referred to within a condition using #If.
Why should this be? And what else works like this? Obviously I can simply leave it as it is and use it this way, but somehow, it seems like it might possbly be useful to me in the future if I had some clue about where this came from and what else I might learn from it. :)
Any clues will be gratefully accepted.
Thanks,
Paul