Results 1 to 11 of 11

Thread: Objects available

  1. #1

    Thread Starter
    Frenzied Member swatty's Avatar
    Join Date
    Aug 2002
    Location
    somewhere on earth
    Posts
    1,478

    Objects available

    How can we determine which objects are available on users machine ?

    I'm adding functionality to email of fax the reports generated by the app.

    When outlook isn't installed on the machine i would set the button disabled.
    The same for the fax server.

    How can i check if these classes are installed on the machine ?

    Now I am creating the objects when the button is clicked.
    This will throw an error when the component isn't available.

    Someone.
    Code:
    If Question = Incomplete Then
       AnswerNextOne
    Else
       ReplyIfKnown
    End If
    cu Swatty

  2. #2
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456
    Well - You can create a test function in which you can check what all classes are available. For instance, you could do something like this ...

    VB Code:
    1. on error resume next
    2.  
    3. dim lobjOutlook as new Outlook.Application ' or whatever
    4.  
    5. if err.number <> 0 then
    6.     ' class not installed or not found ....
    7. end if

    Run this test procedure in the beginning and if it return false disable your buttons ...
    Its not the most elegant of ways of doing something but its sure as hell is easy.

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    For Outlook you can check the following registry key

    HKEY_CLASSES_ROOT\Outlook.Application\CurVer

    if it has a value then Outlook is installed

  4. #4

    Thread Starter
    Frenzied Member swatty's Avatar
    Join Date
    Aug 2002
    Location
    somewhere on earth
    Posts
    1,478
    I'll try for techy's aproach not a proper one but effective.

    The registry key would not exist (i think ) if not installed.
    Code:
    If Question = Incomplete Then
       AnswerNextOne
    Else
       ReplyIfKnown
    End If
    cu Swatty

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    Originally posted by swatty
    I'll try for techy's aproach not a proper one but effective.

    The registry key would not exist (i think ) if not installed.
    True, but if the key didn't exist you'd get a trappable error.

    Also, you wouldn't have to wait for the Outlook object to load, and the complications that come with creating it (on some machines you get a second visible instance, and some will close the main Outlook window if you terminate your object).

  6. #6

    Thread Starter
    Frenzied Member swatty's Avatar
    Join Date
    Aug 2002
    Location
    somewhere on earth
    Posts
    1,478
    What do you think about
    VB Code:
    1. On Error Resume Next
    2.    Dim obj As Object
    3.    Set obj = CreateObject("Outlook.Application")
    4.    If Err.Number <> 0 Then
    5.       Err.Clear
    6.       On Error Resume Next
    7.       NO_MAIL = True
    8.    End If
    9.    Set obj = Nothing
    10.    Set obj = CreateObject("FaxServer.FaxServer")
    11.    If Err.Number <> 0 Then
    12.       Err.Clear
    13.       NO_FAX = True
    14.    End If
    15.    Set obj = Nothing
    Code:
    If Question = Incomplete Then
       AnswerNextOne
    Else
       ReplyIfKnown
    End If
    cu Swatty

  7. #7
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456
    Originally posted by si_the_geek
    True, but if the key didn't exist you'd get a trappable error.

    Also, you wouldn't have to wait for the Outlook object to load, and the complications that come with creating it (on some machines you get a second visible instance, and some will close the main Outlook window if you terminate your object).
    What ????? You are kidding me alright. I have done this before and it does not do anything like that.

  8. #8

    Thread Starter
    Frenzied Member swatty's Avatar
    Join Date
    Aug 2002
    Location
    somewhere on earth
    Posts
    1,478
    Originally posted by si_the_geek
    True, but if the key didn't exist you'd get a trappable error.

    Also, you wouldn't have to wait for the Outlook object to load, and the complications that come with creating it (on some machines you get a second visible instance, and some will close the main Outlook window if you terminate your object).
    Do you have an example of retrieving regKey values.

    Or can I get it with Getsetting.
    Code:
    If Question = Incomplete Then
       AnswerNextOne
    Else
       ReplyIfKnown
    End If
    cu Swatty

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    Originally posted by techyspecy
    What ????? You are kidding me alright. I have done this before and it does not do anything like that.
    I said on SOME machines, it doesn't happen on many - I have only seen it on a small percentage of machines.. and not all the time, but it does happen occasionally.

  10. #10
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    Originally posted by swatty
    Do you have an example of retrieving regKey values.

    Or can I get it with Getsetting.
    You can't use Getsetting, there are lots of example .bas modules around the web that have all the required registry functions in - there's some good ones at www.freevbcode.com

  11. #11
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456
    Originally posted by si_the_geek
    I said on SOME machines, it doesn't happen on many - I have only seen it on a small percentage of machines.. and not all the time, but it does happen occasionally.
    What do you mean on some machines and not on others ...

Posting Permissions

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



Click Here to Expand Forum to Full Width