Outlook Express

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tom Becker

    Outlook Express


    Is there a way, from Access, to programmaticall y click the Send and
    Receive button in Outlook?

  • Tom van Stiphout

    #2
    Re: Outlook Express

    On Thu, 02 Mar 2006 17:03:36 -0600, Tom Becker
    <wlkhjdo89ioudh @hotmail.com> wrote:

    Get the Window Handle of that button, and send (PostMessage) it a
    WM_CLICK message.
    Why don't you tell us what you really want to do. Send emails perhaps?
    How about DoCmd.SendObjec t?

    -Tom.

    [color=blue]
    >
    >Is there a way, from Access, to programmaticall y click the Send and
    >Receive button in Outlook?[/color]

    Comment

    • CDMAPoster@FortuneJames.com

      #3
      Re: Outlook Express

      Tom Becker wrote:[color=blue]
      > Is there a way, from Access, to programmaticall y click the Send and
      > Receive button in Outlook?[/color]

      T.B., here is an A2K mdb code snippet from about five years ago for
      plain Outlook 2K:

      'Send/Receive
      Set MyExplorer = objOutlook.Acti veExplorer
      MyExplorer.Acti vate
      MyExplorer.Wind owState = olMaximized
      Set MyMenuBar = MyExplorer.Comm andBars.Item("S tandard")
      Set MyMenuBarContro l = MyMenuBar.Contr ols.Item("Send/Re&ceive")
      MyMenuBarContro l.Execute
      Set MyMenuBar = Nothing

      Some Dim's:
      Dim MyExplorer As Explorer
      Dim MyMenuBar As CommandBar
      Dim MyMenuBarContro l As CommandBarContr ol
      Dim objOutlook As Outlook.Applica tion

      This needs a reference set to the Outlook Object library. I dug up
      this example before I noticed the word "Express" in your subject line
      but it may give you some ideas. Note that Outlook is easier to
      automate than Outlook Express.

      James A. Fortune
      CDMAPoster@Fort uneJames.com

      Comment

      • Tom Becker

        #4
        Re: Re: Outlook Express

        On Thu, 02 Mar 2006 22:06:11 -0700, Tom van Stiphout
        <no.spam.tom774 4@cox.net> wrote:
        [color=blue]
        >On Thu, 02 Mar 2006 17:03:36 -0600, Tom Becker
        ><wlkhjdo89ioud h@hotmail.com> wrote:
        >
        >Get the Window Handle of that button, and send (PostMessage) it a
        >WM_CLICK message.
        >Why don't you tell us what you really want to do. Send emails perhaps?
        >How about DoCmd.SendObjec t?
        >
        >-Tom.[/color]

        Can you tell me more about Window Handles of buttons and WM_CLICK?

        I use DoCmd.SendObjec t but sometimes it's sits in the Outbox in
        Outlook. I want to make sure it sends the email right away by clicking
        Send and Receive.

        [color=blue]
        >
        >[color=green]
        >>
        >>Is there a way, from Access, to programmaticall y click the Send and
        >>Receive button in Outlook?[/color][/color]

        Comment

        • Tom van Stiphout

          #5
          Re: Outlook Express

          On Fri, 03 Mar 2006 05:45:08 -0600, Tom Becker
          <wlkhjdo89ioudh @hotmail.com> wrote:

          Window handles etc are related to low-level Windows API programming.
          Not recommended but as the very last resort.

          "Sometimes it sits in the Outbox" sounds more like a configuration or
          connectivity problem than a programming problem.

          -Tom.

          [color=blue]
          >On Thu, 02 Mar 2006 22:06:11 -0700, Tom van Stiphout
          ><no.spam.tom77 44@cox.net> wrote:
          >[color=green]
          >>On Thu, 02 Mar 2006 17:03:36 -0600, Tom Becker
          >><wlkhjdo89iou dh@hotmail.com> wrote:
          >>
          >>Get the Window Handle of that button, and send (PostMessage) it a
          >>WM_CLICK message.
          >>Why don't you tell us what you really want to do. Send emails perhaps?
          >>How about DoCmd.SendObjec t?
          >>
          >>-Tom.[/color]
          >
          > Can you tell me more about Window Handles of buttons and WM_CLICK?
          >
          > I use DoCmd.SendObjec t but sometimes it's sits in the Outbox in
          >Outlook. I want to make sure it sends the email right away by clicking
          >Send and Receive.
          >
          >[color=green]
          >>
          >>[color=darkred]
          >>>
          >>>Is there a way, from Access, to programmaticall y click the Send and
          >>>Receive button in Outlook?[/color][/color][/color]

          Comment

          • Tom Becker

            #6
            Re: Re: Outlook Express

            On 2 Mar 2006 23:40:16 -0800, CDMAPoster@Fort uneJames.com wrote:
            [color=blue]
            >Tom Becker wrote:[color=green]
            >> Is there a way, from Access, to programmaticall y click the Send and
            >> Receive button in Outlook?[/color]
            >
            >T.B., here is an A2K mdb code snippet from about five years ago for
            >plain Outlook 2K:
            >
            >'Send/Receive
            >Set MyExplorer = objOutlook.Acti veExplorer
            >MyExplorer.Act ivate
            >MyExplorer.Win dowState = olMaximized
            >Set MyMenuBar = MyExplorer.Comm andBars.Item("S tandard")
            >Set MyMenuBarContro l = MyMenuBar.Contr ols.Item("Send/Re&ceive")
            >MyMenuBarContr ol.Execute
            >Set MyMenuBar = Nothing
            >
            >Some Dim's:
            >Dim MyExplorer As Explorer
            >Dim MyMenuBar As CommandBar
            >Dim MyMenuBarContro l As CommandBarContr ol
            >Dim objOutlook As Outlook.Applica tion
            >
            >This needs a reference set to the Outlook Object library. I dug up
            >this example before I noticed the word "Express" in your subject line
            >but it may give you some ideas. Note that Outlook is easier to
            >automate than Outlook Express.
            >
            >James A. Fortune
            >CDMAPoster@For tuneJames.com[/color]

            Thanks! It looks like I need to change something to make it work in
            Access 2002 though. It is with Outlook and not Outlook Express.

            I get an error on this line:
            Set MyExplorer = objOutlook.Acti veExplorer

            The error says, "object variable or with block not set"

            Dimming As CommandBar didn't work when when I added a reference to
            Microsoft Outlook 10.0 object library, but it did work when I also
            added Microsoft Office 10.0 object library.

            Any ideas on what needs to be done?

            Comment

            • Tom Becker

              #7
              Re: Re: Outlook Express

              On Fri, 03 Mar 2006 06:37:27 -0700, Tom van Stiphout
              <no.spam.tom774 4@cox.net> wrote:
              [color=blue]
              >On Fri, 03 Mar 2006 05:45:08 -0600, Tom Becker
              ><wlkhjdo89ioud h@hotmail.com> wrote:
              >
              >Window handles etc are related to low-level Windows API programming.
              >Not recommended but as the very last resort.
              >
              >"Sometimes it sits in the Outbox" sounds more like a configuration or
              >connectivity problem than a programming problem.
              >
              >-Tom.
              >[/color]
              On the configuration possibility I could check on the settings in
              Outlook, But is there anything I can do about a connectivity problem?
              This is over a LAN.

              Comment

              • CDMAPoster@FortuneJames.com

                #8
                Re: Outlook Express

                Tom Becker wrote:[color=blue]
                > On 2 Mar 2006 23:40:16 -0800, CDMAPoster@Fort uneJames.com wrote:
                >[color=green]
                > >Tom Becker wrote:[color=darkred]
                > >> Is there a way, from Access, to programmaticall y click the Send and
                > >> Receive button in Outlook?[/color]
                > >
                > >T.B., here is an A2K mdb code snippet from about five years ago for
                > >plain Outlook 2K:
                > >
                > >'Send/Receive
                > >Set MyExplorer = objOutlook.Acti veExplorer
                > >MyExplorer.Act ivate
                > >MyExplorer.Win dowState = olMaximized
                > >Set MyMenuBar = MyExplorer.Comm andBars.Item("S tandard")
                > >Set MyMenuBarContro l = MyMenuBar.Contr ols.Item("Send/Re&ceive")
                > >MyMenuBarContr ol.Execute
                > >Set MyMenuBar = Nothing
                > >
                > >Some Dim's:
                > >Dim MyExplorer As Explorer
                > >Dim MyMenuBar As CommandBar
                > >Dim MyMenuBarContro l As CommandBarContr ol
                > >Dim objOutlook As Outlook.Applica tion
                > >
                > >This needs a reference set to the Outlook Object library. I dug up
                > >this example before I noticed the word "Express" in your subject line
                > >but it may give you some ideas. Note that Outlook is easier to
                > >automate than Outlook Express.
                > >
                > >James A. Fortune
                > >CDMAPoster@For tuneJames.com[/color]
                >
                > Thanks! It looks like I need to change something to make it work in
                > Access 2002 though. It is with Outlook and not Outlook Express.
                >
                > I get an error on this line:
                > Set MyExplorer = objOutlook.Acti veExplorer
                >
                > The error says, "object variable or with block not set"
                >
                > Dimming As CommandBar didn't work when when I added a reference to
                > Microsoft Outlook 10.0 object library, but it did work when I also
                > added Microsoft Office 10.0 object library.
                >
                > Any ideas on what needs to be done?[/color]

                I like your initiative. It needs a little more. Run a function to see
                if outlook is running. If it's not running, I did:

                Shell ("C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\O UTLOOK.EXE")
                For I = 1 To 1700
                DoEvents
                Next I

                before

                Set objOutlook = GetObject("", "Outlook.Applic ation")

                Another way is to use CreateObject for the case when outlook is not
                running. Something like:

                Set objOutlook = CreateObject("" , "Outlook.Applic ation")

                before running the Send/Receive code.

                Also, be careful to set objects back to Nothing when you're done using
                them so that Access can close Outlook. That should get you close.

                James A. Fortune
                CDMAPoster@Fort uneJames.com

                Verisign wants a perpetual unsupervised monopoly on the .COM registry:



                Comment

                • Wayne Gillespie

                  #9
                  Re: Outlook Express

                  On 3 Mar 2006 15:17:34 -0800, CDMAPoster@Fort uneJames.com wrote:
                  [color=blue]
                  >I like your initiative. It needs a little more. Run a function to see
                  >if outlook is running. If it's not running, I did:
                  >[/color]

                  **Based on code from Stephen Lebans

                  Function fIsOulookThere( ) As Integer
                  ' Open the installed Version of MS Outlook
                  Dim OL As Object

                  On Error Resume Next
                  'See if Outlook is running
                  Err.Clear
                  ' Is Outlook running?
                  Set OL = GetObject(, "Outlook.Applic ation")
                  ' Error if not running
                  If Err.Number <> 0 Then
                  ' Clear Error object
                  Err.Clear
                  'Create a new instance of Outlook
                  Set OL = CreateObject("O utlook.Applicat ion")
                  If Err.Number <> 0 Then
                  'not installed
                  fIsOulookThere = 0
                  Else
                  'installed but not running
                  fIsOulookThere = 2
                  End If
                  Else
                  'yes it is running
                  fIsOulookThere = 1
                  End If

                  If Not IsEmpty(OL) Then Set OL = Nothing

                  End Function

                  Wayne Gillespie
                  Gosford NSW Australia

                  Comment

                  • Tom Becker

                    #10
                    Re: Re: Outlook Express

                    On 3 Mar 2006 15:17:34 -0800, CDMAPoster@Fort uneJames.com wrote:
                    [color=blue]
                    >Tom Becker wrote:[color=green]
                    >> On 2 Mar 2006 23:40:16 -0800, CDMAPoster@Fort uneJames.com wrote:
                    >>[color=darkred]
                    >> >Tom Becker wrote:
                    >> >> Is there a way, from Access, to programmaticall y click the Send and
                    >> >> Receive button in Outlook?
                    >> >
                    >> >T.B., here is an A2K mdb code snippet from about five years ago for
                    >> >plain Outlook 2K:
                    >> >
                    >> >'Send/Receive
                    >> >Set MyExplorer = objOutlook.Acti veExplorer
                    >> >MyExplorer.Act ivate
                    >> >MyExplorer.Win dowState = olMaximized
                    >> >Set MyMenuBar = MyExplorer.Comm andBars.Item("S tandard")
                    >> >Set MyMenuBarContro l = MyMenuBar.Contr ols.Item("Send/Re&ceive")
                    >> >MyMenuBarContr ol.Execute
                    >> >Set MyMenuBar = Nothing
                    >> >
                    >> >Some Dim's:
                    >> >Dim MyExplorer As Explorer
                    >> >Dim MyMenuBar As CommandBar
                    >> >Dim MyMenuBarContro l As CommandBarContr ol
                    >> >Dim objOutlook As Outlook.Applica tion
                    >> >
                    >> >This needs a reference set to the Outlook Object library. I dug up
                    >> >this example before I noticed the word "Express" in your subject line
                    >> >but it may give you some ideas. Note that Outlook is easier to
                    >> >automate than Outlook Express.
                    >> >
                    >> >James A. Fortune
                    >> >CDMAPoster@For tuneJames.com[/color]
                    >>
                    >> Thanks! It looks like I need to change something to make it work in
                    >> Access 2002 though. It is with Outlook and not Outlook Express.
                    >>
                    >> I get an error on this line:
                    >> Set MyExplorer = objOutlook.Acti veExplorer
                    >>
                    >> The error says, "object variable or with block not set"
                    >>
                    >> Dimming As CommandBar didn't work when when I added a reference to
                    >> Microsoft Outlook 10.0 object library, but it did work when I also
                    >> added Microsoft Office 10.0 object library.
                    >>
                    >> Any ideas on what needs to be done?[/color]
                    >
                    >I like your initiative. It needs a little more. Run a function to see
                    >if outlook is running. If it's not running, I did:
                    >
                    > Shell ("C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\O UTLOOK.EXE")
                    > For I = 1 To 1700
                    > DoEvents
                    > Next I
                    >
                    >before
                    >
                    >Set objOutlook = GetObject("", "Outlook.Applic ation")
                    >
                    >Another way is to use CreateObject for the case when outlook is not
                    >running. Something like:
                    >
                    >Set objOutlook = CreateObject("" , "Outlook.Applic ation")
                    >
                    >before running the Send/Receive code.
                    >
                    >Also, be careful to set objects back to Nothing when you're done using
                    >them so that Access can close Outlook. That should get you close.[/color]

                    Thanks! I want to try it when I go back on monday. But do you have a
                    function that sees if Outlook is running?

                    [color=blue]
                    >
                    >James A. Fortune
                    >CDMAPoster@For tuneJames.com
                    >
                    >Verisign wants a perpetual unsupervised monopoly on the .COM registry:
                    >
                    >http://www.bobparsons.com/EconomicsLesson.html[/color]

                    Comment

                    • Tom Becker

                      #11
                      Re: Re: Outlook Express

                      On Fri, 03 Mar 2006 23:54:09 GMT, Wayne Gillespie
                      <bestfit@NOhotm ailSPAM.com.au> wrote:
                      [color=blue]
                      >On 3 Mar 2006 15:17:34 -0800, CDMAPoster@Fort uneJames.com wrote:
                      >[color=green]
                      >>I like your initiative. It needs a little more. Run a function to see
                      >>if outlook is running. If it's not running, I did:
                      >>[/color]
                      >
                      >**Based on code from Stephen Lebans
                      >
                      >Function fIsOulookThere( ) As Integer
                      >' Open the installed Version of MS Outlook
                      >Dim OL As Object
                      >
                      >On Error Resume Next
                      >'See if Outlook is running
                      >Err.Clear
                      >' Is Outlook running?
                      >Set OL = GetObject(, "Outlook.Applic ation")
                      >' Error if not running
                      >If Err.Number <> 0 Then
                      > ' Clear Error object
                      > Err.Clear
                      > 'Create a new instance of Outlook
                      > Set OL = CreateObject("O utlook.Applicat ion")
                      > If Err.Number <> 0 Then
                      > 'not installed
                      > fIsOulookThere = 0
                      > Else
                      > 'installed but not running
                      > fIsOulookThere = 2
                      > End If
                      >Else
                      > 'yes it is running
                      > fIsOulookThere = 1
                      >End If
                      >
                      >If Not IsEmpty(OL) Then Set OL = Nothing
                      >
                      >End Function
                      >
                      >Wayne Gillespie
                      >Gosford NSW Australia[/color]

                      That works! Thanks!

                      Comment

                      • Tom Becker

                        #12
                        Re: Re: Outlook Express

                        On 3 Mar 2006 15:17:34 -0800, CDMAPoster@Fort uneJames.com wrote:
                        [color=blue]
                        >Tom Becker wrote:[color=green]
                        >> On 2 Mar 2006 23:40:16 -0800, CDMAPoster@Fort uneJames.com wrote:
                        >>[color=darkred]
                        >> >Tom Becker wrote:
                        >> >> Is there a way, from Access, to programmaticall y click the Send and
                        >> >> Receive button in Outlook?
                        >> >
                        >> >T.B., here is an A2K mdb code snippet from about five years ago for
                        >> >plain Outlook 2K:
                        >> >
                        >> >'Send/Receive
                        >> >Set MyExplorer = objOutlook.Acti veExplorer
                        >> >MyExplorer.Act ivate
                        >> >MyExplorer.Win dowState = olMaximized
                        >> >Set MyMenuBar = MyExplorer.Comm andBars.Item("S tandard")
                        >> >Set MyMenuBarContro l = MyMenuBar.Contr ols.Item("Send/Re&ceive")
                        >> >MyMenuBarContr ol.Execute
                        >> >Set MyMenuBar = Nothing
                        >> >
                        >> >Some Dim's:
                        >> >Dim MyExplorer As Explorer
                        >> >Dim MyMenuBar As CommandBar
                        >> >Dim MyMenuBarContro l As CommandBarContr ol
                        >> >Dim objOutlook As Outlook.Applica tion
                        >> >
                        >> >This needs a reference set to the Outlook Object library. I dug up
                        >> >this example before I noticed the word "Express" in your subject line
                        >> >but it may give you some ideas. Note that Outlook is easier to
                        >> >automate than Outlook Express.
                        >> >
                        >> >James A. Fortune
                        >> >CDMAPoster@For tuneJames.com[/color]
                        >>
                        >> Thanks! It looks like I need to change something to make it work in
                        >> Access 2002 though. It is with Outlook and not Outlook Express.
                        >>
                        >> I get an error on this line:
                        >> Set MyExplorer = objOutlook.Acti veExplorer
                        >>
                        >> The error says, "object variable or with block not set"
                        >>
                        >> Dimming As CommandBar didn't work when when I added a reference to
                        >> Microsoft Outlook 10.0 object library, but it did work when I also
                        >> added Microsoft Office 10.0 object library.
                        >>
                        >> Any ideas on what needs to be done?[/color]
                        >
                        >I like your initiative. It needs a little more. Run a function to see
                        >if outlook is running. If it's not running, I did:
                        >
                        > Shell ("C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\O UTLOOK.EXE")
                        > For I = 1 To 1700
                        > DoEvents
                        > Next I
                        >
                        >before
                        >
                        >Set objOutlook = GetObject("", "Outlook.Applic ation")
                        >
                        >Another way is to use CreateObject for the case when outlook is not
                        >running. Something like:
                        >
                        >Set objOutlook = CreateObject("" , "Outlook.Applic ation")
                        >
                        >before running the Send/Receive code.
                        >
                        >Also, be careful to set objects back to Nothing when you're done using
                        >them so that Access can close Outlook. That should get you close.
                        >
                        >James A. Fortune
                        >CDMAPoster@For tuneJames.com
                        >
                        >Verisign wants a perpetual unsupervised monopoly on the .COM registry:
                        >
                        >http://www.bobparsons.com/EconomicsLesson.html[/color]

                        Thanks again for looking into this. But with Outlook running and
                        trying it in Access 2000 I get the error on

                        Set MyExplorer = objOutlook.Acti veExplorer

                        Comment

                        • CDMAPoster@FortuneJames.com

                          #13
                          Re: Outlook Express


                          Tom Becker wrote:[color=blue]
                          > On 3 Mar 2006 15:17:34 -0800, CDMAPoster@Fort uneJames.com wrote:
                          >[color=green]
                          > >Tom Becker wrote:[color=darkred]
                          > >> On 2 Mar 2006 23:40:16 -0800, CDMAPoster@Fort uneJames.com wrote:
                          > >>
                          > >> >Tom Becker wrote:
                          > >> >> Is there a way, from Access, to programmaticall y click the Send and
                          > >> >> Receive button in Outlook?
                          > >> >
                          > >> >T.B., here is an A2K mdb code snippet from about five years ago for
                          > >> >plain Outlook 2K:
                          > >> >
                          > >> >'Send/Receive
                          > >> >Set MyExplorer = objOutlook.Acti veExplorer
                          > >> >MyExplorer.Act ivate
                          > >> >MyExplorer.Win dowState = olMaximized
                          > >> >Set MyMenuBar = MyExplorer.Comm andBars.Item("S tandard")
                          > >> >Set MyMenuBarContro l = MyMenuBar.Contr ols.Item("Send/Re&ceive")
                          > >> >MyMenuBarContr ol.Execute
                          > >> >Set MyMenuBar = Nothing
                          > >> >
                          > >> >Some Dim's:
                          > >> >Dim MyExplorer As Explorer
                          > >> >Dim MyMenuBar As CommandBar
                          > >> >Dim MyMenuBarContro l As CommandBarContr ol
                          > >> >Dim objOutlook As Outlook.Applica tion
                          > >> >
                          > >> >This needs a reference set to the Outlook Object library. I dug up
                          > >> >this example before I noticed the word "Express" in your subject line
                          > >> >but it may give you some ideas. Note that Outlook is easier to
                          > >> >automate than Outlook Express.
                          > >> >
                          > >> >James A. Fortune
                          > >> >CDMAPoster@For tuneJames.com
                          > >>
                          > >> Thanks! It looks like I need to change something to make it work in
                          > >> Access 2002 though. It is with Outlook and not Outlook Express.
                          > >>
                          > >> I get an error on this line:
                          > >> Set MyExplorer = objOutlook.Acti veExplorer
                          > >>
                          > >> The error says, "object variable or with block not set"
                          > >>
                          > >> Dimming As CommandBar didn't work when when I added a reference to
                          > >> Microsoft Outlook 10.0 object library, but it did work when I also
                          > >> added Microsoft Office 10.0 object library.
                          > >>
                          > >> Any ideas on what needs to be done?[/color]
                          > >
                          > >I like your initiative. It needs a little more. Run a function to see
                          > >if outlook is running. If it's not running, I did:
                          > >
                          > > Shell ("C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\O UTLOOK.EXE")
                          > > For I = 1 To 1700
                          > > DoEvents
                          > > Next I
                          > >
                          > >before
                          > >
                          > >Set objOutlook = GetObject("", "Outlook.Applic ation")
                          > >
                          > >Another way is to use CreateObject for the case when outlook is not
                          > >running. Something like:
                          > >
                          > >Set objOutlook = CreateObject("" , "Outlook.Applic ation")
                          > >
                          > >before running the Send/Receive code.
                          > >
                          > >Also, be careful to set objects back to Nothing when you're done using
                          > >them so that Access can close Outlook. That should get you close.
                          > >
                          > >James A. Fortune
                          > >CDMAPoster@For tuneJames.com
                          > >
                          > >Verisign wants a perpetual unsupervised monopoly on the .COM registry:
                          > >
                          > >http://www.bobparsons.com/EconomicsLesson.html[/color]
                          >
                          > Thanks again for looking into this. But with Outlook running and
                          > trying it in Access 2000 I get the error on
                          >
                          > Set MyExplorer = objOutlook.Acti veExplorer[/color]

                          I know the code I posted worked with Outlook 2K. Let's see if the
                          automation part is working. Make sure the reference to 'OLE
                          Automation' is set :-). Will objOutlook let you do something simple
                          like minimize Outlook?

                          James A. Fortune
                          CDMAPoster@Fort uneJames.com

                          Comment

                          • Tom Becker

                            #14
                            Outlook problem

                            On 4 Mar 2006 16:14:16 -0800, CDMAPoster@Fort uneJames.com wrote:
                            [color=blue]
                            >
                            >Tom Becker wrote:[color=green]
                            >> On 3 Mar 2006 15:17:34 -0800, CDMAPoster@Fort uneJames.com wrote:
                            >>[color=darkred]
                            >> >Tom Becker wrote:
                            >> >> On 2 Mar 2006 23:40:16 -0800, CDMAPoster@Fort uneJames.com wrote:
                            >> >>
                            >> >> >Tom Becker wrote:
                            >> >> >> Is there a way, from Access, to programmaticall y click the Send and
                            >> >> >> Receive button in Outlook?
                            >> >> >
                            >> >> >T.B., here is an A2K mdb code snippet from about five years ago for
                            >> >> >plain Outlook 2K:
                            >> >> >
                            >> >> >'Send/Receive
                            >> >> >Set MyExplorer = objOutlook.Acti veExplorer
                            >> >> >MyExplorer.Act ivate
                            >> >> >MyExplorer.Win dowState = olMaximized
                            >> >> >Set MyMenuBar = MyExplorer.Comm andBars.Item("S tandard")
                            >> >> >Set MyMenuBarContro l = MyMenuBar.Contr ols.Item("Send/Re&ceive")
                            >> >> >MyMenuBarContr ol.Execute
                            >> >> >Set MyMenuBar = Nothing
                            >> >> >
                            >> >> >Some Dim's:
                            >> >> >Dim MyExplorer As Explorer
                            >> >> >Dim MyMenuBar As CommandBar
                            >> >> >Dim MyMenuBarContro l As CommandBarContr ol
                            >> >> >Dim objOutlook As Outlook.Applica tion
                            >> >> >
                            >> >> >This needs a reference set to the Outlook Object library. I dug up
                            >> >> >this example before I noticed the word "Express" in your subject line
                            >> >> >but it may give you some ideas. Note that Outlook is easier to
                            >> >> >automate than Outlook Express.
                            >> >> >
                            >> >> >James A. Fortune
                            >> >> >CDMAPoster@For tuneJames.com
                            >> >>
                            >> >> Thanks! It looks like I need to change something to make it work in
                            >> >> Access 2002 though. It is with Outlook and not Outlook Express.
                            >> >>
                            >> >> I get an error on this line:
                            >> >> Set MyExplorer = objOutlook.Acti veExplorer
                            >> >>
                            >> >> The error says, "object variable or with block not set"
                            >> >>
                            >> >> Dimming As CommandBar didn't work when when I added a reference to
                            >> >> Microsoft Outlook 10.0 object library, but it did work when I also
                            >> >> added Microsoft Office 10.0 object library.
                            >> >>
                            >> >> Any ideas on what needs to be done?
                            >> >
                            >> >I like your initiative. It needs a little more. Run a function to see
                            >> >if outlook is running. If it's not running, I did:
                            >> >
                            >> > Shell ("C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\O UTLOOK.EXE")
                            >> > For I = 1 To 1700
                            >> > DoEvents
                            >> > Next I
                            >> >
                            >> >before
                            >> >
                            >> >Set objOutlook = GetObject("", "Outlook.Applic ation")
                            >> >
                            >> >Another way is to use CreateObject for the case when outlook is not
                            >> >running. Something like:
                            >> >
                            >> >Set objOutlook = CreateObject("" , "Outlook.Applic ation")
                            >> >
                            >> >before running the Send/Receive code.
                            >> >
                            >> >Also, be careful to set objects back to Nothing when you're done using
                            >> >them so that Access can close Outlook. That should get you close.
                            >> >
                            >> >James A. Fortune
                            >> >CDMAPoster@For tuneJames.com
                            >> >
                            >> >Verisign wants a perpetual unsupervised monopoly on the .COM registry:
                            >> >
                            >> >http://www.bobparsons.com/EconomicsLesson.html[/color]
                            >>
                            >> Thanks again for looking into this. But with Outlook running and
                            >> trying it in Access 2000 I get the error on
                            >>
                            >> Set MyExplorer = objOutlook.Acti veExplorer[/color]
                            >
                            >I know the code I posted worked with Outlook 2K. Let's see if the
                            >automation part is working. Make sure the reference to 'OLE
                            >Automation' is set :-). Will objOutlook let you do something simple
                            >like minimize Outlook?
                            >[/color]

                            OLE Automation is checked. It won't do anything. I get an error
                            message on the first line of the code saying:

                            Object Variable or With Block not set.

                            I am trying it with Outlook2K.


                            Comment

                            • CDMAPoster@FortuneJames.com

                              #15
                              Re: Outlook problem

                              I'll post the entire list of referenced I used, tonight or tomorrow.
                              After that, if you still have difficulties I'll try to help you find
                              the problem. It has to be something pretty simple.

                              James A. Fortune
                              CDMAPoster@Fort uneJames.com

                              Comment

                              Working...