UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Can't Open Outlook From Access With Simplest Code, Office 2007    
 
   
Soule
post Dec 20 2011, 08:37 PM
Post #1

UtterAccess Enthusiast
Posts: 64



I'm going to scream so loud my desktop monitor screen won't survive...

I cannot get these simplest of test codes to execute. I'm just trying to open Outlook using vb code behind a button on an Access form. (IMG:style_emoticons/default/crazy.gif)

1) Dim olApp As Outlook.Application

Set olApp = New Outlook.Application

OR

2) Dim olApp As Outlook.Application

Set olApp = CreateObject("Outlook.Application")


I added both the "Microsoft Access 12.0 Object Library" and "Microsoft Outlook 12.0 Object Library" to my References.

All relevant Visible properties are set to "yes".

Both code versions run without errors (my F8/Step Into debugging feature not working is another issue; I have the Special Keys in Options checked. (IMG:style_emoticons/default/pullhair.gif) )....but Outlook doesn't open.

Nothing is working. How could a two line block of code not work. Only Microsoft could make that a reality. (IMG:style_emoticons/default/dazed.gif)

Please rescue me from this limbo before I'm awarded a digital limbotamy.

That is all.

Thank you.
Go to the top of the page
 
+
RJD
post Dec 20 2011, 09:05 PM
Post #2

UtterAccess Ruler
Posts: 1,404
From: Gulf South USA



Hi Soule: If you are just trying to open Outlook, with no email creation, you might try something like:

CODE
Call Shell("outlook.exe", vbMaximizedFocus)


For email creation, more code is required. Let us know if you are trying to create a new email and someone can share the code for that as well.

HTH
Joe
Go to the top of the page
 
+
merlenicholson
post Dec 20 2011, 10:24 PM
Post #3

UtterAccess Veteran
Posts: 348
From: Tampa, Florida, USA - UTC -5:00



Here's my Outlook button - Access 2003, Win 7 x64, uses reference "Microsoft Outlook 14.0 Object Library". It opens a new email with subject and a signature.
CODE
Private Sub OpenOutlook_Click()
' ****************************************************************************
Dim mess_body As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
' ****************************************************************************
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
' ****************************************************************************
MailOutLook.BodyFormat = olFormatRichText
MailOutLook.Subject = "xxxxxx xxxxxxxx"
MailOutLook.Body = "Thanks," & vbCrLf & "Buffy and Biff" & vbCrLf & vbCrLf
MailOutLook.BodyFormat = olFormatHTML
MailOutLook.Display
End Sub


This post has been edited by merlenicholson: Dec 20 2011, 10:26 PM
Go to the top of the page
 
+
RJD
post Dec 20 2011, 10:47 PM
Post #4

UtterAccess Ruler
Posts: 1,404
From: Gulf South USA



...or if you just want the email address included in a new email:

CODE
Application.FollowHyperlink "Mailto:" & mailaddress


...with the [mailaddress] gotten from elsewhere.

Joe
Go to the top of the page
 
+
HiTechCoach
post Jan 6 2012, 04:13 PM
Post #5

UtterAccess VIP
Posts: 18,396
From: Oklahoma City, Oklahoma



QUOTE (Soule @ Dec 20 2011, 07:37 PM) *
I'm going to scream so loud my desktop monitor screen won't survive...

I cannot get these simplest of test codes to execute. I'm just trying to open Outlook using vb code behind a button on an Access form. (IMG:style_emoticons/default/crazy.gif)

1) Dim olApp As Outlook.Application

Set olApp = New Outlook.Application

OR

2) Dim olApp As Outlook.Application

Set olApp = CreateObject("Outlook.Application")


I added both the "Microsoft Access 12.0 Object Library" and "Microsoft Outlook 12.0 Object Library" to my References.

All relevant Visible properties are set to "yes".

Both code versions run without errors (my F8/Step Into debugging feature not working is another issue; I have the Special Keys in Options checked. (IMG:style_emoticons/default/pullhair.gif) )....but Outlook doesn't open.

Nothing is working. How could a two line block of code not work. Only Microsoft could make that a reality. (IMG:style_emoticons/default/dazed.gif)

Please rescue me from this limbo before I'm awarded a digital limbotamy.

That is all.

Thank you.



The code is probably working. It is just not doing what you expect. The code creates an Outlook Object in memory. Nothing will be visitable to the end user.

This code you posted is not for opening outlook but for Outlook automation with VBA code. This is normally used to perform actions with Outlook without any user interaction. The user will normally not see anything.
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 19th May 2013 - 06:59 AM