Hello,
I have a spreadsheet that contains some code, listed below, which I run on a daily basis. For some reason it does not work today, and shows the error message below:
Run time error ' -2147319779 (8002801d)':
Auotmation Error
Library not registered
The code is shown below:
Sub SendCLTEmail()
'References needed :
'Microsoft Outlook Object Library
'Microsoft Scripting Runtime
'Dimension variables
Dim olApp As Outlook.Application, olMail As Outlook.MailItem
Dim FSObj As Scripting.FileSystemObject, TStream As Scripting.TextStream
Dim rngeSend As Range, strHTMLBody As String
Sheets("CLT Email").Select
ActiveSheet.Calculate
If Range("B2").Value <> Sheets("CONTROL").Range("P3").Value And Range("B4").Value <> Sheets("CONTROL").Range("P5").Value Then
MsgBox "CLT Email p&ls have not been updated!", vbOKOnly + vbExclamation, "OLD DATA!!!"
End If
'Set the range to be sent
Set rngeSend = Sheets("CLT Email").Range("A1:Z50")
'Now create the HTML file
ActiveWorkbook.PublishObjects.Add(xlSourceRange, "L:\London Rates\Middle Office\Favourites\sht.htm", rngeSend.Parent.Name, rngeSend.Address, xlHtmlStatic).Publish True
'Create an instance of Outlook (or use existing instance if it already exists
Set olApp = CreateObject("Outlook.Application")
'Create a mail item
Set olMail = olApp.CreateItem(olMailItem)
'Open the HTML file using the FilesystemObject into a TextStream object
* The line below is where the error message appears*
Set FSObj = New Scripting.FileSystemObject
Set TStream = FSObj.OpenTextFile("L:\London Rates\Middle Office\Favourites\sht.htm", ForReading)
'Now set the HTMLBody property of the message to the text contained in the TextStream object
strHTMLBody = TStream.ReadAll
olMail.HTMLBody = strHTMLBody
olMail.To = "Address"
olMail.Subject = "Report"
olMail.Display
End Sub
Thanks.
I have a spreadsheet that contains some code, listed below, which I run on a daily basis. For some reason it does not work today, and shows the error message below:
Run time error ' -2147319779 (8002801d)':
Auotmation Error
Library not registered
The code is shown below:
Sub SendCLTEmail()
'References needed :
'Microsoft Outlook Object Library
'Microsoft Scripting Runtime
'Dimension variables
Dim olApp As Outlook.Application, olMail As Outlook.MailItem
Dim FSObj As Scripting.FileSystemObject, TStream As Scripting.TextStream
Dim rngeSend As Range, strHTMLBody As String
Sheets("CLT Email").Select
ActiveSheet.Calculate
If Range("B2").Value <> Sheets("CONTROL").Range("P3").Value And Range("B4").Value <> Sheets("CONTROL").Range("P5").Value Then
MsgBox "CLT Email p&ls have not been updated!", vbOKOnly + vbExclamation, "OLD DATA!!!"
End If
'Set the range to be sent
Set rngeSend = Sheets("CLT Email").Range("A1:Z50")
'Now create the HTML file
ActiveWorkbook.PublishObjects.Add(xlSourceRange, "L:\London Rates\Middle Office\Favourites\sht.htm", rngeSend.Parent.Name, rngeSend.Address, xlHtmlStatic).Publish True
'Create an instance of Outlook (or use existing instance if it already exists
Set olApp = CreateObject("Outlook.Application")
'Create a mail item
Set olMail = olApp.CreateItem(olMailItem)
'Open the HTML file using the FilesystemObject into a TextStream object
* The line below is where the error message appears*
Set FSObj = New Scripting.FileSystemObject
Set TStream = FSObj.OpenTextFile("L:\London Rates\Middle Office\Favourites\sht.htm", ForReading)
'Now set the HTMLBody property of the message to the text contained in the TextStream object
strHTMLBody = TStream.ReadAll
olMail.HTMLBody = strHTMLBody
olMail.To = "Address"
olMail.Subject = "Report"
olMail.Display
End Sub
Thanks.