473,791 Members | 2,725 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Curious about odd construction: "#If OutlookEnabled"

prn
254 Recognized Expert Contributor
I have some inherited code that I don't understand properly. It involves sending email from Access using OLE and Outlook. I've stripped it down to the relevant bits here. Specifically, the construction that (I know that) I don't understand is this:

Expand|Select|Wrap|Line Numbers
  1.     #If OutlookEnabled Then
  2.         Dim olApp As Outlook.Application
  3.         Dim olNewMaiItem As MailItem
  4.         Set olApp = CreateObject("OutLook.Application")
  5.         MsgBox "olApp created - Version = " & olApp.Version
  6.     #Else
  7.         MsgBox "Outlook not enabled"
  8.     #End If
  9.  
(Of course, instead of just displaying the "olApp created" MsgBox, it really does a bunch of other stuff, but I think I mostly understand that part.)

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
Dec 4 '08
10 2531
prn
254 Recognized Expert Contributor
Interesting ideas. I'll look into them.

Thanks,
Paul
Dec 5 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

9
4401
by: LRW | last post by:
I'm not exactly sure how to even ask the question, and I know my terminology is not good as I'm a SQL beginner, but, here goes. I need to find a way to make an if statement within an array...or, the "while" portion of a recordset. The best way I can ask is show what I mean. http://oscarguy.mechphisto.net/awardbrowse.php If you go there and select an award (like Best Picture), leave the year field alone, and select YES and submit,...
6
2463
by: Fabrice Régnier | last post by:
Hi ;) Everything is in the title. the prob is "boo" is displayed ! Can you believe it ? Thanx for anyone who can help me. fabrice.
1
18909
by: Mark Richards | last post by:
The solutions for the following problems seems to be simple but I did not found a (convenient) solution: Assume we have a number of elements of the same type under a common parent e.g. <person ... myattr="aaa">Paul</person> <person ... myattr="bbb">Peter</person> <person ... myattr="ccc">Karl</person> ..... <person ... myattr="ddd">Stan</person>
5
2081
by: kmunderwood | last post by:
I am trying to combine "if match=" and "when test" I am a newbie, and have made both work separately, but I can not seem to combine them. This is my xml("index.xml")page(I can not change this, it comes to me this way. <?xml version="1.0" encoding="iso-8859-1" ?>
145
6352
by: Sidney Cadot | last post by:
Hi all, In a discussion with Tak-Shing Chan the question came up whether the as-if rule can cover I/O functions. Basically, he maintains it can, and I think it doesn't. Consider two programs: /*** a.c ***/
35
2741
by: David Cleaver | last post by:
Hello all, I was wondering if there were some sort of limitations on the "if" statement? I'm writing a program which needs to check a bunch of conditions all at the same time (basically). And I'm pretty sure the rest of the program is working just fine. The only thing I could think might be wrong is that the if statement can only hold so many values in itself? Let me show what I'm doing: if (table001]>>5]&b&0x1f] != 0 &&
2
2073
by: marsarden | last post by:
write code like: int main(void) { int a=10; if(a<20) {} } Compiler ok on dev-cpp . don't we have to add a ";" after if
37
3989
by: jht5945 | last post by:
For example I wrote a function: function Func() { // do something } we can call it like: var obj = new Func(); // call it as a constructor or var result = Func(); // call it as a function
0
882
by: jack | last post by:
IF you want to meet your old school mate's & college mate's of your life there is a chance, just enter school or college details in the below site http://www.batchmates.com/institution/regform.asp?refid=1529710&reflink=31481 please forward to ur friend's tell to them forward this message to there friend's
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9993
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2913
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.