How do you send keystrokes to Outlook from Access? 
Author Message
 How do you send keystrokes to Outlook from Access?

Hi,

I've read and implemented the 'How to send an email plus attachement' code
from Access and it works great.  The only thing it doesn't do is to actually
tell Outlook to do a Send/Receive.  Can someone tell me if there's a VBA
procedure for doing this or if not, how do I use VBA to send keystrokes to
the Outlook app in order to simulate a user hitting the send/receive button?

TIA



Sat, 03 Apr 2004 00:04:11 GMT  
 How do you send keystrokes to Outlook from Access?
Try this:

Public Sub SendNow()

   'Flush the OutBox and recieve new messages
   'an Outlook session, check mail and close the session.

   'the following lines with "late" binding so a reference is not required in the mdb
   Dim objApp As Variant 'Outlook.Application
   Dim ctl As Variant 'Office.CommandBarControl
   Dim cb As Variant 'Office.CommandBar

   On Error Resume Next
   Set objApp = GetObject(, "Outlook.Application")
   If objApp Is Nothing Then
      Set objApp = CreateObject("Outlook.Application")
   End If

   Set cb = objApp.ActiveExplorer.CommandBars("Standard")
   Set ctl = cb.FindControl(ID:=5488, Recursive:=True)
   ctl.Execute

   Set objApp = Nothing
   Set ctl = Nothing
   Set cb = Nothing
End Sub

Steve

Quote:

> Hi,

> I've read and implemented the 'How to send an email plus attachement' code
> from Access and it works great.  The only thing it doesn't do is to actually
> tell Outlook to do a Send/Receive.  Can someone tell me if there's a VBA
> procedure for doing this or if not, how do I use VBA to send keystrokes to
> the Outlook app in order to simulate a user hitting the send/receive button?

> TIA



Sat, 03 Apr 2004 00:19:54 GMT  
 How do you send keystrokes to Outlook from Access?
Steve,

Thanks for the post.  I need to reconfigure my Outlook to use dial-up
networking but it looks as though it'll work great.

Can you explain to me a little bit about the following lines :-

   Set cb = objApp.ActiveExplorer.CommandBars("Standard")
   Set ctl = cb.FindControl(ID:=5488, Recursive:=True)
   ctl.Execute

Cheers.
M

Try this:

Public Sub SendNow()

   'Flush the OutBox and recieve new messages
   'an Outlook session, check mail and close the session.

   'the following lines with "late" binding so a reference is not required
in the mdb
   Dim objApp As Variant 'Outlook.Application
   Dim ctl As Variant 'Office.CommandBarControl
   Dim cb As Variant 'Office.CommandBar

   On Error Resume Next
   Set objApp = GetObject(, "Outlook.Application")
   If objApp Is Nothing Then
      Set objApp = CreateObject("Outlook.Application")
   End If

   Set cb = objApp.ActiveExplorer.CommandBars("Standard")
   Set ctl = cb.FindControl(ID:=5488, Recursive:=True)
   ctl.Execute

   Set objApp = Nothing
   Set ctl = Nothing
   Set cb = Nothing
End Sub

Steve


Quote:
> Hi,

> I've read and implemented the 'How to send an email plus attachement' code
> from Access and it works great.  The only thing it doesn't do is to
actually
> tell Outlook to do a Send/Receive.  Can someone tell me if there's a VBA
> procedure for doing this or if not, how do I use VBA to send keystrokes to
> the Outlook app in order to simulate a user hitting the send/receive
button?

> TIA



Sat, 03 Apr 2004 02:03:49 GMT  
 How do you send keystrokes to Outlook from Access?
Steve,

Just tried this and everything worked EXCEPT when it was ment to do a
send/receive.  The outlook app opened and shut down correctly, but there was
no send/receive in the middle.  Any thoughts?

Try this:

Public Sub SendNow()

   'Flush the OutBox and recieve new messages
   'an Outlook session, check mail and close the session.

   'the following lines with "late" binding so a reference is not required
in the mdb
   Dim objApp As Variant 'Outlook.Application
   Dim ctl As Variant 'Office.CommandBarControl
   Dim cb As Variant 'Office.CommandBar

   On Error Resume Next
   Set objApp = GetObject(, "Outlook.Application")
   If objApp Is Nothing Then
      Set objApp = CreateObject("Outlook.Application")
   End If

   Set cb = objApp.ActiveExplorer.CommandBars("Standard")
   Set ctl = cb.FindControl(ID:=5488, Recursive:=True)
   ctl.Execute

   Set objApp = Nothing
   Set ctl = Nothing
   Set cb = Nothing
End Sub

Steve


Quote:
> Hi,

> I've read and implemented the 'How to send an email plus attachement' code
> from Access and it works great.  The only thing it doesn't do is to
actually
> tell Outlook to do a Send/Receive.  Can someone tell me if there's a VBA
> procedure for doing this or if not, how do I use VBA to send keystrokes to
> the Outlook app in order to simulate a user hitting the send/receive
button?

> TIA



Sat, 03 Apr 2004 02:11:51 GMT  
 How do you send keystrokes to Outlook from Access?
Hmmm...

So I just tried it with "late" binding and it didn't seem to work.

Change the following code and set a reference to Outlook then retry:

Dim objApp As .Application
Dim ctl As Office.CommandBarControl
Dim cb As Office.CommandBar

Quote:

> Steve,

> Just tried this and everything worked EXCEPT when it was ment to do a
> send/receive.  The outlook app opened and shut down correctly, but there was
> no send/receive in the middle.  Any thoughts?


> Try this:

> Public Sub SendNow()

>    'Flush the OutBox and recieve new messages
>    'an Outlook session, check mail and close the session.

>    'the following lines with "late" binding so a reference is not required
> in the mdb
>    Dim objApp As Variant 'Outlook.Application
>    Dim ctl As Variant 'Office.CommandBarControl
>    Dim cb As Variant 'Office.CommandBar

>    On Error Resume Next
>    Set objApp = GetObject(, "Outlook.Application")
>    If objApp Is Nothing Then
>       Set objApp = CreateObject("Outlook.Application")
>    End If

>    Set cb = objApp.ActiveExplorer.CommandBars("Standard")
>    Set ctl = cb.FindControl(ID:=5488, Recursive:=True)
>    ctl.Execute

>    Set objApp = Nothing
>    Set ctl = Nothing
>    Set cb = Nothing
> End Sub

> Steve



> > Hi,

> > I've read and implemented the 'How to send an email plus attachement' code
> > from Access and it works great.  The only thing it doesn't do is to
> actually
> > tell Outlook to do a Send/Receive.  Can someone tell me if there's a VBA
> > procedure for doing this or if not, how do I use VBA to send keystrokes to
> > the Outlook app in order to simulate a user hitting the send/receive
> button?

> > TIA



Sat, 03 Apr 2004 03:17:11 GMT  
 How do you send keystrokes to Outlook from Access?
Correction!
Dim objApp As Outlook.Application

Hmmm...

So I just tried it with "late" binding and it didn't seem to work.

Change the following code and set a reference to Outlook then retry:

Dim objApp As .Application
Dim ctl As Office.CommandBarControl
Dim cb As Office.CommandBar

Quote:

> Steve,

> Just tried this and everything worked EXCEPT when it was ment to do a
> send/receive.  The outlook app opened and shut down correctly, but there was
> no send/receive in the middle.  Any thoughts?


> Try this:

> Public Sub SendNow()

>    'Flush the OutBox and recieve new messages
>    'an Outlook session, check mail and close the session.

>    'the following lines with "late" binding so a reference is not required
> in the mdb
>    Dim objApp As Variant 'Outlook.Application
>    Dim ctl As Variant 'Office.CommandBarControl
>    Dim cb As Variant 'Office.CommandBar

>    On Error Resume Next
>    Set objApp = GetObject(, "Outlook.Application")
>    If objApp Is Nothing Then
>       Set objApp = CreateObject("Outlook.Application")
>    End If

>    Set cb = objApp.ActiveExplorer.CommandBars("Standard")
>    Set ctl = cb.FindControl(ID:=5488, Recursive:=True)
>    ctl.Execute

>    Set objApp = Nothing
>    Set ctl = Nothing
>    Set cb = Nothing
> End Sub

> Steve



> > Hi,

> > I've read and implemented the 'How to send an email plus attachement' code
> > from Access and it works great.  The only thing it doesn't do is to
> actually
> > tell Outlook to do a Send/Receive.  Can someone tell me if there's a VBA
> > procedure for doing this or if not, how do I use VBA to send keystrokes to
> > the Outlook app in order to simulate a user hitting the send/receive
> button?

> > TIA



Sat, 03 Apr 2004 03:47:23 GMT  
 How do you send keystrokes to Outlook from Access?
Hey Steve,

I implemented my first Outlook VBA code today and everything works great.
One question for you tho. It only seems to work when outlook is open or it
opens the logon dialog box.  Can I code the logon settings in my VBA so that
I can kick this job off without having to be logged into Outlook....and, so
that at the end of the processing the outlook sessions closes down again?
This seems to be a major issue round my clients office.  There are lots of
jobs that we kick off during the night.....this would be a great feature if
I can get around it.

Thanks,

Rick


Correction!
Dim objApp As Outlook.Application

Hmmm...

So I just tried it with "late" binding and it didn't seem to work.

Change the following code and set a reference to Outlook then retry:

Dim objApp As .Application
Dim ctl As Office.CommandBarControl
Dim cb As Office.CommandBar


Quote:
> Steve,

> Just tried this and everything worked EXCEPT when it was ment to do a
> send/receive.  The outlook app opened and shut down correctly, but there
was
> no send/receive in the middle.  Any thoughts?


> Try this:

> Public Sub SendNow()

>    'Flush the OutBox and recieve new messages
>    'an Outlook session, check mail and close the session.

>    'the following lines with "late" binding so a reference is not required
> in the mdb
>    Dim objApp As Variant 'Outlook.Application
>    Dim ctl As Variant 'Office.CommandBarControl
>    Dim cb As Variant 'Office.CommandBar

>    On Error Resume Next
>    Set objApp = GetObject(, "Outlook.Application")
>    If objApp Is Nothing Then
>       Set objApp = CreateObject("Outlook.Application")
>    End If

>    Set cb = objApp.ActiveExplorer.CommandBars("Standard")
>    Set ctl = cb.FindControl(ID:=5488, Recursive:=True)
>    ctl.Execute

>    Set objApp = Nothing
>    Set ctl = Nothing
>    Set cb = Nothing
> End Sub

> Steve



> > Hi,

> > I've read and implemented the 'How to send an email plus attachement'
code
> > from Access and it works great.  The only thing it doesn't do is to
> actually
> > tell Outlook to do a Send/Receive.  Can someone tell me if there's a VBA
> > procedure for doing this or if not, how do I use VBA to send keystrokes
to
> > the Outlook app in order to simulate a user hitting the send/receive
> button?

> > TIA



Mon, 05 Apr 2004 23:55:42 GMT  
 How do you send keystrokes to Outlook from Access?
Hi Steve,

Still didn't work.  Outlook opened correctly invisably but didn't kick off a
send/receive.  I made sure that a default profile was selected so that there
isn't any additional info Outlook needs before it can log you on.  Any more
ideas?

Matt.

Correction!
Dim objApp As Outlook.Application

Hmmm...

So I just tried it with "late" binding and it didn't seem to work.

Change the following code and set a reference to Outlook then retry:

Dim objApp As .Application
Dim ctl As Office.CommandBarControl
Dim cb As Office.CommandBar


Quote:
> Steve,

> Just tried this and everything worked EXCEPT when it was ment to do a
> send/receive.  The outlook app opened and shut down correctly, but there
was
> no send/receive in the middle.  Any thoughts?


> Try this:

> Public Sub SendNow()

>    'Flush the OutBox and recieve new messages
>    'an Outlook session, check mail and close the session.

>    'the following lines with "late" binding so a reference is not required
> in the mdb
>    Dim objApp As Variant 'Outlook.Application
>    Dim ctl As Variant 'Office.CommandBarControl
>    Dim cb As Variant 'Office.CommandBar

>    On Error Resume Next
>    Set objApp = GetObject(, "Outlook.Application")
>    If objApp Is Nothing Then
>       Set objApp = CreateObject("Outlook.Application")
>    End If

>    Set cb = objApp.ActiveExplorer.CommandBars("Standard")
>    Set ctl = cb.FindControl(ID:=5488, Recursive:=True)
>    ctl.Execute

>    Set objApp = Nothing
>    Set ctl = Nothing
>    Set cb = Nothing
> End Sub

> Steve



> > Hi,

> > I've read and implemented the 'How to send an email plus attachement'
code
> > from Access and it works great.  The only thing it doesn't do is to
> actually
> > tell Outlook to do a Send/Receive.  Can someone tell me if there's a VBA
> > procedure for doing this or if not, how do I use VBA to send keystrokes
to
> > the Outlook app in order to simulate a user hitting the send/receive
> button?

> > TIA



Wed, 07 Apr 2004 04:17:36 GMT  
 How do you send keystrokes to Outlook from Access?
Quote:
> Hi Steve,

> Still didn't work.  Outlook opened correctly invisably but didn't kick off
a
> send/receive.  I made sure that a default profile was selected so that
there
> isn't any additional info Outlook needs before it can log you on.  Any
more
> ideas?

> Matt.


> Correction!
> Dim objApp As Outlook.Application


> Hmmm...

> So I just tried it with "late" binding and it didn't seem to work.

> Change the following code and set a reference to Outlook then retry:

> Dim objApp As .Application
> Dim ctl As Office.CommandBarControl
> Dim cb As Office.CommandBar



> > Steve,

> > Just tried this and everything worked EXCEPT when it was ment to do a
> > send/receive.  The outlook app opened and shut down correctly, but there
> was
> > no send/receive in the middle.  Any thoughts?


> > Try this:

> > Public Sub SendNow()

> >    'Flush the OutBox and recieve new messages
> >    'an Outlook session, check mail and close the session.

> >    'the following lines with "late" binding so a reference is not
required
> > in the mdb
> >    Dim objApp As Variant 'Outlook.Application
> >    Dim ctl As Variant 'Office.CommandBarControl
> >    Dim cb As Variant 'Office.CommandBar

> >    On Error Resume Next
> >    Set objApp = GetObject(, "Outlook.Application")
> >    If objApp Is Nothing Then
> >       Set objApp = CreateObject("Outlook.Application")
> >    End If

> >    Set cb = objApp.ActiveExplorer.CommandBars("Standard")
> >    Set ctl = cb.FindControl(ID:=5488, Recursive:=True)
> >    ctl.Execute

> >    Set objApp = Nothing
> >    Set ctl = Nothing
> >    Set cb = Nothing
> > End Sub

> > Steve



> > > Hi,

> > > I've read and implemented the 'How to send an email plus attachement'
> code
> > > from Access and it works great.  The only thing it doesn't do is to
> > actually
> > > tell Outlook to do a Send/Receive.  Can someone tell me if there's a
VBA
> > > procedure for doing this or if not, how do I use VBA to send
keystrokes
> to
> > > the Outlook app in order to simulate a user hitting the send/receive
> > button?

> > > TIA



Wed, 07 Apr 2004 23:10:17 GMT  
 How do you send keystrokes to Outlook from Access?
Hi, if you are on a network then using docmd.sendobject
will send an email from within access without the hassle
of a send/receive command in outlook.

luck
Jonathan

Quote:
>-----Original Message-----
>> Hi Steve,

>> Still didn't work.  Outlook opened correctly invisably
but didn't kick off
>a
>> send/receive.  I made sure that a default profile was
selected so that
>there
>> isn't any additional info Outlook needs before it can
log you on.  Any
>more
>> ideas?

>> Matt.




Quote:
>> Correction!
>> Dim objApp As Outlook.Application




Quote:
>> Hmmm...

>> So I just tried it with "late" binding and it didn't
seem to work.

>> Change the following code and set a reference to
Outlook then retry:

>> Dim objApp As .Application
>> Dim ctl As Office.CommandBarControl
>> Dim cb As Office.CommandBar




win.server.ntlworld.com...
Quote:
>> > Steve,

>> > Just tried this and everything worked EXCEPT when it
was ment to do a
>> > send/receive.  The outlook app opened and shut down

correctly, but there
Quote:
>> was
>> > no send/receive in the middle.  Any thoughts?




- Show quoted text -

Quote:
>> > Try this:

>> > Public Sub SendNow()

>> >    'Flush the OutBox and recieve new messages
>> >    'an Outlook session, check mail and close the
session.

>> >    'the following lines with "late" binding so a
reference is not
>required
>> > in the mdb
>> >    Dim objApp As Variant 'Outlook.Application
>> >    Dim ctl As Variant 'Office.CommandBarControl
>> >    Dim cb As Variant 'Office.CommandBar

>> >    On Error Resume Next
>> >    Set objApp = GetObject(, "Outlook.Application")
>> >    If objApp Is Nothing Then
>> >       Set objApp = CreateObject("Outlook.Application")
>> >    End If

>> >    Set cb = objApp.ActiveExplorer.CommandBars
("Standard")
>> >    Set ctl = cb.FindControl(ID:=5488, Recursive:=True)
>> >    ctl.Execute

>> >    Set objApp = Nothing
>> >    Set ctl = Nothing
>> >    Set cb = Nothing
>> > End Sub

>> > Steve




win.server.ntlworld.com...
Quote:
>> > > Hi,

>> > > I've read and implemented the 'How to send an email
plus attachement'
>> code
>> > > from Access and it works great.  The only thing it
doesn't do is to
>> > actually
>> > > tell Outlook to do a Send/Receive.  Can someone

tell me if there's a

- Show quoted text -

Quote:
>VBA
>> > > procedure for doing this or if not, how do I use
VBA to send
>keystrokes
>> to
>> > > the Outlook app in order to simulate a user hitting
the send/receive
>> > button?

>> > > TIA

>.



Fri, 09 Apr 2004 16:40:25 GMT  
 How do you send keystrokes to Outlook from Access?
Hi, if you are on a network then using docmd.sendobject
will send an email from within access without the hassle
of a send/receive command in outlook.

luck
Jonathan

Quote:
>-----Original Message-----
>> Hi Steve,

>> Still didn't work.  Outlook opened correctly invisably
but didn't kick off
>a
>> send/receive.  I made sure that a default profile was
selected so that
>there
>> isn't any additional info Outlook needs before it can
log you on.  Any
>more
>> ideas?

>> Matt.




Quote:
>> Correction!
>> Dim objApp As Outlook.Application




Quote:
>> Hmmm...

>> So I just tried it with "late" binding and it didn't
seem to work.

>> Change the following code and set a reference to
Outlook then retry:

>> Dim objApp As .Application
>> Dim ctl As Office.CommandBarControl
>> Dim cb As Office.CommandBar




win.server.ntlworld.com...
Quote:
>> > Steve,

>> > Just tried this and everything worked EXCEPT when it
was ment to do a
>> > send/receive.  The outlook app opened and shut down

correctly, but there
Quote:
>> was
>> > no send/receive in the middle.  Any thoughts?




- Show quoted text -

Quote:
>> > Try this:

>> > Public Sub SendNow()

>> >    'Flush the OutBox and recieve new messages
>> >    'an Outlook session, check mail and close the
session.

>> >    'the following lines with "late" binding so a
reference is not
>required
>> > in the mdb
>> >    Dim objApp As Variant 'Outlook.Application
>> >    Dim ctl As Variant 'Office.CommandBarControl
>> >    Dim cb As Variant 'Office.CommandBar

>> >    On Error Resume Next
>> >    Set objApp = GetObject(, "Outlook.Application")
>> >    If objApp Is Nothing Then
>> >       Set objApp = CreateObject("Outlook.Application")
>> >    End If

>> >    Set cb = objApp.ActiveExplorer.CommandBars
("Standard")
>> >    Set ctl = cb.FindControl(ID:=5488, Recursive:=True)
>> >    ctl.Execute

>> >    Set objApp = Nothing
>> >    Set ctl = Nothing
>> >    Set cb = Nothing
>> > End Sub

>> > Steve




win.server.ntlworld.com...
Quote:
>> > > Hi,

>> > > I've read and implemented the 'How to send an email
plus attachement'
>> code
>> > > from Access and it works great.  The only thing it
doesn't do is to
>> > actually
>> > > tell Outlook to do a Send/Receive.  Can someone

tell me if there's a

- Show quoted text -

Quote:
>VBA
>> > > procedure for doing this or if not, how do I use
VBA to send
>keystrokes
>> to
>> > > the Outlook app in order to simulate a user hitting
the send/receive
>> > button?

>> > > TIA

>.



Fri, 09 Apr 2004 16:40:47 GMT  
 How do you send keystrokes to Outlook from Access?
Hi, if you are on a network then using docmd.sendobject
will send an email from within access without the hassle
of a send/receive command in outlook.

luck
Jonathan

Quote:
>-----Original Message-----
>> Hi Steve,

>> Still didn't work.  Outlook opened correctly invisably
but didn't kick off
>a
>> send/receive.  I made sure that a default profile was
selected so that
>there
>> isn't any additional info Outlook needs before it can
log you on.  Any
>more
>> ideas?

>> Matt.




Quote:
>> Correction!
>> Dim objApp As Outlook.Application




Quote:
>> Hmmm...

>> So I just tried it with "late" binding and it didn't
seem to work.

>> Change the following code and set a reference to
Outlook then retry:

>> Dim objApp As .Application
>> Dim ctl As Office.CommandBarControl
>> Dim cb As Office.CommandBar




win.server.ntlworld.com...
Quote:
>> > Steve,

>> > Just tried this and everything worked EXCEPT when it
was ment to do a
>> > send/receive.  The outlook app opened and shut down

correctly, but there
Quote:
>> was
>> > no send/receive in the middle.  Any thoughts?




- Show quoted text -

Quote:
>> > Try this:

>> > Public Sub SendNow()

>> >    'Flush the OutBox and recieve new messages
>> >    'an Outlook session, check mail and close the
session.

>> >    'the following lines with "late" binding so a
reference is not
>required
>> > in the mdb
>> >    Dim objApp As Variant 'Outlook.Application
>> >    Dim ctl As Variant 'Office.CommandBarControl
>> >    Dim cb As Variant 'Office.CommandBar

>> >    On Error Resume Next
>> >    Set objApp = GetObject(, "Outlook.Application")
>> >    If objApp Is Nothing Then
>> >       Set objApp = CreateObject("Outlook.Application")
>> >    End If

>> >    Set cb = objApp.ActiveExplorer.CommandBars
("Standard")
>> >    Set ctl = cb.FindControl(ID:=5488, Recursive:=True)
>> >    ctl.Execute

>> >    Set objApp = Nothing
>> >    Set ctl = Nothing
>> >    Set cb = Nothing
>> > End Sub

>> > Steve




win.server.ntlworld.com...
Quote:
>> > > Hi,

>> > > I've read and implemented the 'How to send an email
plus attachement'
>> code
>> > > from Access and it works great.  The only thing it
doesn't do is to
>> > actually
>> > > tell Outlook to do a Send/Receive.  Can someone

tell me if there's a

- Show quoted text -

Quote:
>VBA
>> > > procedure for doing this or if not, how do I use
VBA to send
>keystrokes
>> to
>> > > the Outlook app in order to simulate a user hitting
the send/receive
>> > button?

>> > > TIA

>.



Fri, 09 Apr 2004 16:40:31 GMT  
 
 [ 12 post ] 

 Relevant Pages 

1. Outlook and Access send.mail

2. Sending Access data to Outlook Express

3. Send Outlook Task from Access

4. Send SMTP Mail from Access without Outlook

5. sEnding Email with Outlook/access

6. Error sending report via Access / Outlook Express

7. Sending Faxes via Access/Outlook - NT W/S

8. How can I send an Access report to Outlook 97 by VBA

9. Sending plain text email via Access 97 and Outlook

10. Sending E_mail through outlook using Access

11. outlook express (sending email in access)

12. Sending an e-mail with Outlook 2000 from within Access

 

 
Powered by phpBB® Forum Software