Results 1 to 13 of 13
  1. #1
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    References problem. (Access 97/SR2)

    I have a database which uses some vba code to email info back to us. This database was then sent to 40 reps. However, the database was set up using the Outlook 9.0 reference (Outlook 2000) and some of the reps are using Outlook 97 (which uses the Outlook 8.0 reference). Is there a way of overcoming this problem, short of issuing 2 different versions of the database depending on which version of outlook they are using?

    P.S. Still searching through the lounge messages with reference to references.... seems to be alot of them, found nothing yet though.
    Any help would be much appreciated.

  2. #2
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    NYC,USA,Earth
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: References problem. (Access 97/SR2)

    One strategy to pursue would be to have the app detect which outlook client was present and set the appropriate reference when the app is first opened. Some sort of switch could be set so this process only occurs when the app is first opened, depending on your distribution method. I seem to remember seeing code examples of setting references through code. Try searching the knowledge base and some of the vb code sites for setting references through code. I'll take a look also and post back if I find anything. Detecting the mail client should be as easy as finding the existence of a dll file. I'm not that familiar with outlook but it seems logical.

  3. #3
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: References problem. (Access 97/SR2)

    Thanks for the suggestion on what to do Paul.
    If I can work out how to set the references, the version of outlook problem isnt as important... if it comes to it they can select which version they use from a dropdown when they first open the database. I may need to do some sort of search for each file anyway, to get the path for the reference.

    I have been looking through previous posts here... somewhat unsuccessfully. Most posts i've read so far seem to skirt the issue, ones that have been helpful look very complicated - that may however be due to the fact that im ill and my brain doesnt seem to be in an understanding mood - might be because its flooded with Lemsip!

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: References problem. (Access 97/SR2)

    The version of Outlook may be important if you're trying to work with the Outlook object model. That is different in Outlook 97 from the later versions, particularly if you've got any security patches on the later versions. How are you using Outlook to send email? Are you addressing the Outlook object model itself or using the CDO library or what?
    Charlotte

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: References problem. (Access 97/SR2)

    Phil,

    For what it's worth: I tried this a while ago and gave up, because the code I wrote kept bombing. I admit I knew even less about Access then than I do now. I decided to create separate databases for each version.

    You'd have to finalize the database on a machine with the oldest version. If you do it on a machine with a newer version, it won't work at all on a machine with an older version - the invalid reference will cause simple VBA functions like Left to be "unknown".

    In the code, you'd have to:

    Loop through the References collection of the database (backwards)
    Check if a reference is broken using the IsBroken property
    Remove a broken reference
    Determine what should replace it
    Create a new reference

    This is awkward, since users might have installed Office in a non-standard location, so you can't just assume it is C:Program FilesMicrosoft Office...

  6. #6
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: References problem. (Access 97/SR2)

    Thanks for your reply Charlotte.
    Not overly sure of the technical terms for what I have used, however, below are the variables for what I have used (hope that helps):

    Dim ol As New Outlook.Application
    Dim ns As Outlook.NameSpace
    Dim newMail As Outlook.MailItem
    'Return a reference to the MAPI layer
    Set ns = ol.GetNamespace("MAPI")
    Set newMail = ol.CreateItem(olMailItem)

    I have tried the application on a machine with Outlook 97 set as a reference and with Outlook 2000 set as a reference, but I changed these manually each time, and they both worked.

    Thanks for your reply Hans.
    If I could find out how, I was planning leaving out the reference altogether when I send the reps the DB, searching for the Outlook 2000 reference and adding it, but if it wasn't found, searching the the outlook 97 reference and adding it.
    Because I'd have to somehow search for the file anyway, I could then get the path from this search.

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: References problem. (Access 97/SR2)

    OK, we were talking about two difference things. Each of the Outlook object libraries has a different name. If I remember correctly, even the extension changed between OL97 and OL98. It's not too hard to remove references in code. Like Hans, though, I've had problems setting them in code. Have you tried late binding instead?
    Charlotte

  8. #8
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: References problem. (Access 97/SR2)

    I think I may have cracked it (untested yet though)!

    Between this post, previous posts and a link from a post to a download which was signed "Charlotte", so the chances are thats the same very helpful Charlotte we know here <img src=/S/hello.gif border=0 alt=hello width=25 height=29>, I may have the solution:

    The Outlook 2000 reference is msoutl9.olb, the 97 one is msoutl8.olb (they are the ones that I got from a pc with windows 95, each version of outlook and nothing else, and this appears to be correct).

    I used this line to add in the reference:
    Application.References.AddFromFile strFilename

    And used a search procedure to find the filename and path for each:
    With Application.FileSearch
    .NewSearch
    .LookIn = "C:"
    .SearchSubFolders = True
    .filename = "msoutl8.olb"
    'Used the same procedure with "msoutl9.olb"
    If .Execute() > 0 Then checkfile = True
    End With
    strFilename = Application.FileSearch.FoundFiles(1)

    I didnt need to add in a facility for reference removal as adding references would only be done when the database was first opened on the machine.
    I have yet to test the whole procedure, but the individual parts seemed to work.
    When I've tested it I'll post again to say whether it worked or not.

    P.S In response to your question Charlotte..... Never heard of late binding, I think i'll have to do some more reading!

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: References problem. (Access 97/SR2)

    If you've got anyone using Outlook 98 instead of 97 or 2000, the filename of the type library for 98 is:

    msoutl85.olb

    Good luck!

  10. #10
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: References problem. (Access 97/SR2)

    Thanks Hans. I'll make sure I note that down for future reference. In this case, I think 97 & 2000 are the only versions being used.

    I've now tested it. On my machine (Outlook 2000, also has the msoutl8.olb file for outlook 97 on the hard drive), it sets the Outlook 2000 reference. On another machine with Outlook 97, it found the msoutl8.olb file and set the Outlook 97 reference. This is only run once when a user first opens the database, as a firstuse setting is already in the database.

    Would it be okay to post the entire code here or would it be breaching peoples/companies rights by "publishing" their code. I used an extract from "the references wizard 1.3", Access help and bits of a few posts here? Just thought i'd check.

  11. #11
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: References problem. (Access 97/SR2)

    It depends on what you post. In general, it is policy here to post a link to a web site or URL whenever possible. If you quote an excerpt from something, you're supposed to give full credit to the author and include any copyright statements included in the original code. If you have a routine that you borrowed bits of from other sources, indicate the sources and post your modified version with appropriate notations. If it's lengthy, post it as an attachment. I don't know what "the refernces wizard 1.3" is, so I can't address that part.

    Edited for afterthoughts - Charlotte
    If the code is copied whole from a book or CD or copied with only minor cosmetic changes, then don't post it here because it's clearly a violation of virtually every copyright notice.
    Charlotte

  12. #12
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: References problem. (Access 97/SR2)

    Well, I could say that late binding happens in the code you write after midnight <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15> but it's actually a method for declaring object variables as a general object type rather than a specific type and then using something like CreateObject to set the variable to a specific object type. Using late binding eliminates the need for a reference set to the object library in question, although it also means you can't lean on intellisense. Here's an example of late binding:

    Dim xlApp As Object
    Set xlApp = CreateObject("excel.application")

    The opposite is early binding which requires an object library reference. With early binding you declare the variable as the specific object type and intellisense works because of the reference set to the object library. This is early binding:

    Dim xlApp As Excel.Application
    Charlotte

  13. #13
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: References problem. (Access 97/SR2)

    Phil, I think you should use late binding. Once you have developed the code with the benefit of the early binding (intellisense prompts), you can comment out the Dim and Set statements that require the Outlook library and substitute the more generic Dim as Object and CreateObject statements. It should be easy to switch back and force to do revisions. Even though the VB engine has to work a bit harder with late binding, it still should be more efficient than conducting a hard drive search. And you'll be ready for XP!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •