Reference Outlook in VBA

N

Noemi

Hi

I have an excel spreadsheet which is used on different versions ie 97 & 2000.

I need to be able to email the spreadsheet using a macro however at the
moment I get a compile error.

We are unable to set the library reference on the 97 version because to save
the form we must run it through 2000 first.

Any idea's what I need to do to set the correct reference using code.

Thanks
 
N

Noemi

Hi Bob
I am trying to use the sample code however the following line stays red and
I dont know why

Set objRecipient.Add("John Wilson")

any idea's as I cannot test it until this is not red anymore.

thanks
 
N

Noemi

Hi Bob

Below is the code I am using, I have marked the line which stays red and I
dont know why.

Dim objOutlook As Object
Dim objNameSpace As Object
Dim objMailItem As Object
Dim objRecipient As Object

Set objOutlook = CreateObject("Outlook.Application")
Set objNameSpace = objOutlook.GetNamespace("MAPI")

Set objMailItem = objOutlook.CreateItem(0)

Set objRecipient.Add("John Wilson") **********Stays Red
objRecipient.Type = 1

objMailItem.Subject = "Testing Only"
objMailItem.Body = "Testing only"
objMailItem.Attachments.Add ActiveWorkbook.FullName

objNameSpace.Logon , , True
objMailItem.Send

Set objRecipient = Nothing
Set objMailItem = Nothing
Set objNameSpace = Nothing
Set objOutlook = Nothing

Thanks
Noemi
 

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