+ Reply to Thread
Results 1 to 9 of 9

GetObject method not work after Call Shell Method

  1. #1
    ben
    Guest

    GetObject method not work after Call Shell Method

    Trying to grab a reference to Outlook.
    I first use the Getobject(,"Outlook.Application") method, this works if
    outlook is open but if's it's not, I use Call Shell("dir string") to open
    Outlook then use GetObject again to attempt to grab reference. This does not
    work. Outlook will open, and be running fine, but VBA refuses to acknowledge
    it being open, UNLESS I step through the code.
    it's almost like it reads the State of office apps before it runs and will
    not change that state unless, i step through, ie... It says outlook is open
    and won't recheck, even if it is opened by code.
    I can not use CreateObject for the last service pack microsoft released
    killed that function for outlook.
    any thoughts?





    --
    When you lose your mind, you free your life.
    Ever Notice how we use '' for comments in our posts even if they aren''t
    expected to go into the code?

  2. #2
    Tom Ogilvy
    Guest

    Re: GetObject method not work after Call Shell Method


    Perhaps something like this will work:

    set obj = Getobject(,"Outlook.Application")
    if obj is Nothing then
    Call Shell("dir string")
    do
    Doevents
    set obj = Getobject(,"Outlook.Application")
    Loop while obj is nothing
    End if


    --
    Regards,
    Tom Ogilvy



    "ben" <&&&&[email protected](remove this if mailing direct)> wrote in
    message news:[email protected]...
    > Trying to grab a reference to Outlook.
    > I first use the Getobject(,"Outlook.Application") method, this works if
    > outlook is open but if's it's not, I use Call Shell("dir string") to open
    > Outlook then use GetObject again to attempt to grab reference. This does

    not
    > work. Outlook will open, and be running fine, but VBA refuses to

    acknowledge
    > it being open, UNLESS I step through the code.
    > it's almost like it reads the State of office apps before it runs and will
    > not change that state unless, i step through, ie... It says outlook is

    open
    > and won't recheck, even if it is opened by code.
    > I can not use CreateObject for the last service pack microsoft released
    > killed that function for outlook.
    > any thoughts?
    >
    >
    >
    >
    >
    > --
    > When you lose your mind, you free your life.
    > Ever Notice how we use '' for comments in our posts even if they aren''t
    > expected to go into the code?




  3. #3
    ben
    Guest

    Re: GetObject method not work after Call Shell Method

    didn't do quite what i expected but doevents definitely changed things up a
    bit. I think I can work through it now.
    Thanks again Tom

    --
    When you lose your mind, you free your life.
    Ever Notice how we use '' for comments in our posts even if they aren''t
    expected to go into the code?


    "Tom Ogilvy" wrote:

    >
    > Perhaps something like this will work:
    >
    > set obj = Getobject(,"Outlook.Application")
    > if obj is Nothing then
    > Call Shell("dir string")
    > do
    > Doevents
    > set obj = Getobject(,"Outlook.Application")
    > Loop while obj is nothing
    > End if
    >
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    >
    > "ben" <&&&&[email protected](remove this if mailing direct)> wrote in
    > message news:[email protected]...
    > > Trying to grab a reference to Outlook.
    > > I first use the Getobject(,"Outlook.Application") method, this works if
    > > outlook is open but if's it's not, I use Call Shell("dir string") to open
    > > Outlook then use GetObject again to attempt to grab reference. This does

    > not
    > > work. Outlook will open, and be running fine, but VBA refuses to

    > acknowledge
    > > it being open, UNLESS I step through the code.
    > > it's almost like it reads the State of office apps before it runs and will
    > > not change that state unless, i step through, ie... It says outlook is

    > open
    > > and won't recheck, even if it is opened by code.
    > > I can not use CreateObject for the last service pack microsoft released
    > > killed that function for outlook.
    > > any thoughts?
    > >
    > >
    > >
    > >
    > >
    > > --
    > > When you lose your mind, you free your life.
    > > Ever Notice how we use '' for comments in our posts even if they aren''t
    > > expected to go into the code?

    >
    >
    >


  4. #4
    keepITcool
    Guest

    Re: GetObject method not work after Call Shell Method


    no need to shell, and no need for doevents.
    i think Tom's code is missing the CreateObject call.

    Iso using a module level object variable I've wrapped it in a
    STATIC function, so it can be easily called troughout your other code.

    Option Explicit

    Static Function olApp() As Object
    Dim oApp As Object

    If oApp Is Nothing Then
    On Error Resume Next
    Set oApp = GetObject(, "Outlook.Application")
    On Error GoTo 0
    If oApp Is Nothing Then
    Set oApp = CreateObject("Outlook.Application")
    End If
    End If
    Set olApp = oApp
    End Function

    Sub foo()
    With olApp
    .GetNamespace("MAPI").GetDefaultFolder(6).Display
    End With
    End Sub



    --
    keepITcool
    | www.XLsupport.com | keepITcool chello nl | amsterdam


    ben wrote in <news:<[email protected]>

    > didn't do quite what i expected but doevents definitely changed
    > things up a bit. I think I can work through it now.
    > Thanks again Tom


  5. #5
    Tom Ogilvy
    Guest

    Re: GetObject method not work after Call Shell Method

    Guess you missed where he said createobject for Outlook had been disabled by
    Microsoft:

    >I can not use CreateObject for the last service pack microsoft released
    >killed that function for outlook.


    --
    Regards,
    Tom Ogilvy


    "keepITcool" <[email protected]> wrote in message
    news:[email protected]...
    >
    > no need to shell, and no need for doevents.
    > i think Tom's code is missing the CreateObject call.
    >
    > Iso using a module level object variable I've wrapped it in a
    > STATIC function, so it can be easily called troughout your other code.
    >
    > Option Explicit
    >
    > Static Function olApp() As Object
    > Dim oApp As Object
    >
    > If oApp Is Nothing Then
    > On Error Resume Next
    > Set oApp = GetObject(, "Outlook.Application")
    > On Error GoTo 0
    > If oApp Is Nothing Then
    > Set oApp = CreateObject("Outlook.Application")
    > End If
    > End If
    > Set olApp = oApp
    > End Function
    >
    > Sub foo()
    > With olApp
    > .GetNamespace("MAPI").GetDefaultFolder(6).Display
    > End With
    > End Sub
    >
    >
    >
    > --
    > keepITcool
    > | www.XLsupport.com | keepITcool chello nl | amsterdam
    >
    >
    > ben wrote in <news:<[email protected]>
    >
    > > didn't do quite what i expected but doevents definitely changed
    > > things up a bit. I think I can work through it now.
    > > Thanks again Tom




  6. #6
    Peter T
    Guest

    Re: GetObject method not work after Call Shell Method

    Ben might also look at the ErrorHandler in this, just in case even Shell
    doesn't work

    http://support.microsoft.com/?scid=kb;en-us;238610

    Regards,
    Peter T

    "Tom Ogilvy" <[email protected]> wrote in message
    news:[email protected]...
    > Guess you missed where he said createobject for Outlook had been disabled

    by
    > Microsoft:
    >
    > >I can not use CreateObject for the last service pack microsoft released
    > >killed that function for outlook.

    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "keepITcool" <[email protected]> wrote in message
    > news:[email protected]...
    > >
    > > no need to shell, and no need for doevents.
    > > i think Tom's code is missing the CreateObject call.
    > >
    > > Iso using a module level object variable I've wrapped it in a
    > > STATIC function, so it can be easily called troughout your other code.
    > >
    > > Option Explicit
    > >
    > > Static Function olApp() As Object
    > > Dim oApp As Object
    > >
    > > If oApp Is Nothing Then
    > > On Error Resume Next
    > > Set oApp = GetObject(, "Outlook.Application")
    > > On Error GoTo 0
    > > If oApp Is Nothing Then
    > > Set oApp = CreateObject("Outlook.Application")
    > > End If
    > > End If
    > > Set olApp = oApp
    > > End Function
    > >
    > > Sub foo()
    > > With olApp
    > > .GetNamespace("MAPI").GetDefaultFolder(6).Display
    > > End With
    > > End Sub
    > >
    > >
    > >
    > > --
    > > keepITcool
    > > | www.XLsupport.com | keepITcool chello nl | amsterdam
    > >
    > >
    > > ben wrote in <news:<[email protected]>
    > >
    > > > didn't do quite what i expected but doevents definitely changed
    > > > things up a bit. I think I can work through it now.
    > > > Thanks again Tom

    >
    >




  7. #7
    keepITcool
    Guest

    Re: GetObject method not work after Call Shell Method

    Yep missed

    Extensive googling didn't find any indication that Microsoft has
    disabled this in a recent release or SP, and frankly it would surprise
    me.

    Posts by Sue Mosher (Outlook MVP) suggest it's more likely
    an antivirus program blocking access to scripting.



    --
    keepITcool
    | www.XLsupport.com | keepITcool chello nl | amsterdam


    Tom Ogilvy wrote in <news:<[email protected]>

    > Guess you missed where he said createobject for Outlook had been
    > disabled by Microsoft:
    >
    > > I can not use CreateObject for the last service pack microsoft
    > > released killed that function for outlook.


  8. #8
    ben
    Guest

    Re: GetObject method not work after Call Shell Method

    actually what happens, i've studied this quite a bit, is that automation was
    turned off for outlook as the Registry Key taht provides for outlook was
    deleted, and Outlook no longer supports the /regserver switch, microsoft.com
    KB provided that information for me. I looked up the automation registry key
    on microsoft.com and it no longer exists for Outlook, though all other office
    applications still work fine.
    --
    When you lose your mind, you free your life.
    Ever Notice how we use '' for comments in our posts even if they aren''t
    expected to go into the code?


    "keepITcool" wrote:

    > Yep missed
    >
    > Extensive googling didn't find any indication that Microsoft has
    > disabled this in a recent release or SP, and frankly it would surprise
    > me.
    >
    > Posts by Sue Mosher (Outlook MVP) suggest it's more likely
    > an antivirus program blocking access to scripting.
    >
    >
    >
    > --
    > keepITcool
    > | www.XLsupport.com | keepITcool chello nl | amsterdam
    >
    >
    > Tom Ogilvy wrote in <news:<[email protected]>
    >
    > > Guess you missed where he said createobject for Outlook had been
    > > disabled by Microsoft:
    > >
    > > > I can not use CreateObject for the last service pack microsoft
    > > > released killed that function for outlook.

    >


  9. #9
    ben
    Guest

    Re: GetObject method not work after Call Shell Method

    thanks peter, oddly enough the workaround they gave is exactly what i had to
    end up doing.

    --
    When you lose your mind, you free your life.
    Ever Notice how we use '' for comments in our posts even if they aren''t
    expected to go into the code?


    "Peter T" wrote:

    > Ben might also look at the ErrorHandler in this, just in case even Shell
    > doesn't work
    >
    > http://support.microsoft.com/?scid=kb;en-us;238610
    >
    > Regards,
    > Peter T
    >
    > "Tom Ogilvy" <[email protected]> wrote in message
    > news:[email protected]...
    > > Guess you missed where he said createobject for Outlook had been disabled

    > by
    > > Microsoft:
    > >
    > > >I can not use CreateObject for the last service pack microsoft released
    > > >killed that function for outlook.

    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > >
    > > "keepITcool" <[email protected]> wrote in message
    > > news:[email protected]...
    > > >
    > > > no need to shell, and no need for doevents.
    > > > i think Tom's code is missing the CreateObject call.
    > > >
    > > > Iso using a module level object variable I've wrapped it in a
    > > > STATIC function, so it can be easily called troughout your other code.
    > > >
    > > > Option Explicit
    > > >
    > > > Static Function olApp() As Object
    > > > Dim oApp As Object
    > > >
    > > > If oApp Is Nothing Then
    > > > On Error Resume Next
    > > > Set oApp = GetObject(, "Outlook.Application")
    > > > On Error GoTo 0
    > > > If oApp Is Nothing Then
    > > > Set oApp = CreateObject("Outlook.Application")
    > > > End If
    > > > End If
    > > > Set olApp = oApp
    > > > End Function
    > > >
    > > > Sub foo()
    > > > With olApp
    > > > .GetNamespace("MAPI").GetDefaultFolder(6).Display
    > > > End With
    > > > End Sub
    > > >
    > > >
    > > >
    > > > --
    > > > keepITcool
    > > > | www.XLsupport.com | keepITcool chello nl | amsterdam
    > > >
    > > >
    > > > ben wrote in <news:<[email protected]>
    > > >
    > > > > didn't do quite what i expected but doevents definitely changed
    > > > > things up a bit. I think I can work through it now.
    > > > > Thanks again Tom

    > >
    > >

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1