L
Lester Lane
Hi,
I had some code in Outlook 2003 that allowed me to bypass the annoying
messages when I sent emails from Access 2003. Now I have upgraded to
2010 and when Outlook is running my code won't even detect it nor will
it create a new instance (failed with a 429 - ActiveX can't create
error).
I also remember that 2010 can pick an account to send through and I
guess the whole routine could be made slicker. Can someone please
explain where I can find examples of code. I'm at a loss even using
the "help" screens. Thanks.
Dim objOutlook As Object ' Note: Must be late-binding.
Dim objNameSpace As Object
Dim objExplorer As Object
Dim blnSuccessful As Boolean
Dim blnNewInstance As Boolean
Dim strFailed As String
Dim i As Integer
'Is an instance of Outlook already open that we can bind to?
On Error Resume Next
Set objOutlook = GetObject(, "Outlook.Application") ==== fails to find
running program
On Error GoTo ErrTrap
If objOutlook Is Nothing Then
'Outlook isn't already running - create a new instance...
Set objOutlook = CreateObject("Outlook.Application") ==== fails
with 429 can't create error
blnNewInstance = True
'We need to instantiate the Visual Basic environment... (messy)
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objExplorer =
objOutlook.Explorers.Add(objNameSpace.Folders(1), 0)
objExplorer.CommandBars.FindControl(, 1695).Execute
objExplorer.Close
Set objNameSpace = Nothing
Set objExplorer = Nothing
End If
......... more code .......
I had some code in Outlook 2003 that allowed me to bypass the annoying
messages when I sent emails from Access 2003. Now I have upgraded to
2010 and when Outlook is running my code won't even detect it nor will
it create a new instance (failed with a 429 - ActiveX can't create
error).
I also remember that 2010 can pick an account to send through and I
guess the whole routine could be made slicker. Can someone please
explain where I can find examples of code. I'm at a loss even using
the "help" screens. Thanks.
Dim objOutlook As Object ' Note: Must be late-binding.
Dim objNameSpace As Object
Dim objExplorer As Object
Dim blnSuccessful As Boolean
Dim blnNewInstance As Boolean
Dim strFailed As String
Dim i As Integer
'Is an instance of Outlook already open that we can bind to?
On Error Resume Next
Set objOutlook = GetObject(, "Outlook.Application") ==== fails to find
running program
On Error GoTo ErrTrap
If objOutlook Is Nothing Then
'Outlook isn't already running - create a new instance...
Set objOutlook = CreateObject("Outlook.Application") ==== fails
with 429 can't create error
blnNewInstance = True
'We need to instantiate the Visual Basic environment... (messy)
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objExplorer =
objOutlook.Explorers.Add(objNameSpace.Folders(1), 0)
objExplorer.CommandBars.FindControl(, 1695).Execute
objExplorer.Close
Set objNameSpace = Nothing
Set objExplorer = Nothing
End If
......... more code .......