How do I fix a VB error message stating that a library is not registered?

f19l

New Member
Joined
Jun 26, 2012
Messages
4
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.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Welcome to MrExcel.

If you select your workbook in the Visual Basic Editor and choose Tools|References, what is checked and are any marked as MISSING?
 
Upvote 0
Welcome to MrExcel.

If you select your workbook in the Visual Basic Editor and choose Tools|References, what is checked and are any marked as MISSING?

The following are ticked:

Visual Basic For Applications
Microsoft Excel 12.0 Object Library
OLE Automation
Microsoft Office 12.0 Object Library
Microsoft Scriptlet Library
Microsoft Scripting Runtime
Microsoft DAO 3.6 Object Library
Microsoft Office Runtime 1.0 Type Library
Microsoft Office 12.0 Object Library
Microsoft Script Control 1.0

Nothing appears to be missing.
 
Upvote 0
I have just checked again and I actually do have Microsoft Outlook 12.0 Object Library already.
 
Upvote 0
Maybe you need to re-register scrrun.dll. At the Windows command prompt type:

regsvr32 scrrun.dll

and press Enter.
 
Upvote 0

Forum statistics

Threads
1,211,435
Messages
6,101,846
Members
447,758
Latest member
jojo3strada

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top