OLE Automation and Mutliple Office Releases
I recently wrote a macro to create an email from Excell. It works fine on my
machine (using Office 2002). When I try to run it on on an office 2000 machine it faults out. I know it is a reference library issue, but I don't know how to handle it. Here is a sample of my code: Sub Mailto(myMessage) Dim OLF As Outlook.MAPIFolder Dim olMailItem As Outlook.MailItem Dim ToContact As Outlook.Recipient mySubject = Range("AK2") myFilename = Range("AK3") myMailTo1 = Range("AM4") 'Save Current File ActiveWorkbook.SaveCopyAs (myFilename) 'Create Email Set OLF = GetObject("", _ "Outlook.Application").GetNamespace("MAPI").GetDef aultFolder(olFolderInbox) Set olMailItem = OLF.Items.Add olMailItem.Subject = mySubject With olMailItem Set ToContact = .Recipients.Add(myMailTo1) .Body = myMessage .Attachments.Add myFilename, olByValue, , _ "Attachment" .Display End With Set ToContact = Nothing Set olMailItem = Nothing Set OLF = Nothing Set fs = CreateObject("Scripting.FileSystemObject") fs.deletefile (myFilename) End Sub |
All times are GMT +1. The time now is 09:07 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com