Opening Outlook from VB - second post

B

Bob

Thanks for the help but I am having a problem getting it
to work.

I turned on the reference for Outlook and entered the
following commands in an attempt to simply open Outlook:

Dim Olook As Outlook.Application
Set Olook = CreateObject("Outlook.Application")
Olook.Application.Visible = True

When it hits the 3rd line, I get and error: "Object does
not suport this property or command."

I am a novice at Access and suspect that I am overlooking
something. Can you help?

-----Original Message-----
I am using the SHELL command to open Outlook from VB
6.0 in Access using the following statement:

retval = Shell("Outlook.exe", 6)
or
retval = Shell("Outlook.exe", vbMinimizedNoFocus)

Outlook opens, but it is maximized and has focus.
Can anyone help me with this?
Thanks.
 
G

Graham Mandeno

Hi Bob

Olook *is* an Application, so you just need:
Olook.Visible = True
 
T

TC

Does outlook have an Application object?

I doubt it.

Try:
OLook.visible = true

HTH,
TC
 
B

Bob

I tried "olook.visible = true" and I get the same error
message.

Also, here is an excerpt from VB Help:
' Make Excel visible through the Application object.
ExcelSheet.Application.Visible = True

There must be another reason it does not work.

-----Original Message-----
Hi Bob

Olook *is* an Application, so you just need:
Olook.Visible = True

--
Good Luck!

Graham Mandeno [Access MVP]
New Zealand - Home of Lord of the Rings


Thanks for the help but I am having a problem getting it
to work.

I turned on the reference for Outlook and entered the
following commands in an attempt to simply open Outlook:

Dim Olook As Outlook.Application
Set Olook = CreateObject("Outlook.Application")
Olook.Application.Visible = True

When it hits the 3rd line, I get and error: "Object does
not suport this property or command."

I am a novice at Access and suspect that I am overlooking
something. Can you help?


I am using the SHELL command to open Outlook from VB
6.0 in Access using the following statement:

retval = Shell("Outlook.exe", 6)
or
retval = Shell("Outlook.exe", vbMinimizedNoFocus)

Outlook opens, but it is maximized and has focus.
Can anyone help me with this?
Thanks.


.
 
B

Bob

I tried "olook.visible = true" and I got the same error
message.

Also, here is an excerpt from VB Help:
' Make Excel visible through the Application object.
ExcelSheet.Application.Visible = True

There must be another reason it does not work.
 
G

Graham Mandeno

Hi Bob

Sorry - I was not aware that an Outlook.Application doesn't have a Visible
property.

Try this:
Dim objApp As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Set objApp = New Outlook.Application
Set objNameSpace = objApp.GetNamespace(Type:="MAPI")
objNameSpace.GetDefaultFolder(olFolderInbox).Display

BTW, the reason your Excel example works is that you are not starting from
the Excel.Application object, but from an Excel.Sheet, which *does* have an
Application property.

--
Good Luck!

Graham Mandeno [Access MVP]
New Zealand - Home of Lord of the Rings


Bob said:
I tried "olook.visible = true" and I get the same error
message.

Also, here is an excerpt from VB Help:
' Make Excel visible through the Application object.
ExcelSheet.Application.Visible = True

There must be another reason it does not work.

-----Original Message-----
Hi Bob

Olook *is* an Application, so you just need:
Olook.Visible = True

--
Good Luck!

Graham Mandeno [Access MVP]
New Zealand - Home of Lord of the Rings


Thanks for the help but I am having a problem getting it
to work.

I turned on the reference for Outlook and entered the
following commands in an attempt to simply open Outlook:

Dim Olook As Outlook.Application
Set Olook = CreateObject("Outlook.Application")
Olook.Application.Visible = True

When it hits the 3rd line, I get and error: "Object does
not suport this property or command."

I am a novice at Access and suspect that I am overlooking
something. Can you help?


-----Original Message-----

-----Original Message-----
I am using the SHELL command to open Outlook from VB
6.0 in Access using the following statement:

retval = Shell("Outlook.exe", 6)
or
retval = Shell("Outlook.exe", vbMinimizedNoFocus)

Outlook opens, but it is maximized and has focus.
Can anyone help me with this?
Thanks.


set it up as an object

see below

Sub send_email(Optional AttachmentPath)

Dim Olook As Outlook.Application
Dim Olookmsg As Outlook.MailItem
Dim Olookrecip As Outlook.Recipient
Dim Olookatt As Outlook.Attachment

Set Olook = CreateObject("Outlook.Application")
Set Olookmsg = Olook.CreateItem(olMailItem)

olook.visible =true

With Olookmsg

Set Olookrecip = .Recipients.Add("Nathan_Grp")

Olookrecip.Type = olTo

.Subject = "This is an Automation test"
.Body = "Test of automation..." & vbCrLf & vbCrLf

.Importance = olImportanceHigh

If Not IsMissing(AttachmentPath) Then
Set Olookatt = .Attachments.Add (AttachmentPath)
End If

For Each Olookrecip In .Recipients
If Not Olookrecip.Resolve Then
Olookmsg.Display
End If
Next

.Send

End With

End Sub

You'll need to turn on your outlook refernces, tools,
references, remove the code you dont want.


.


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top