Greg Truby
MrExcel MVP
- Joined
- Jun 19, 2002
- Messages
- 10,030
OK this has had me doin' the now for three hours. I am just plain out of ideas...
Got new notebook. (Don't get me started...)
Trying to run code that worked perfectly well on old machine, but blowing apart on new machine...
The crux of the matter:
This code worked just fine on the old 'puter. Now she throws a shoe every time. If I change the On Error Resume Next to On Error GoTo 0 before calling GETOBJECT, I get a "Error -2147319779... Library not registered"
I have tried everything I can think of to get this to work and nothing is helping. I have
The only workaround was to change all the DIM statements to declare as generic OBJECTS. Then the code works just fine. But how the devil does one actually fix this? Like I said, the same code runs just fine on my old machine.
Got new notebook. (Don't get me started...)
Trying to run code that worked perfectly well on old machine, but blowing apart on new machine...
The crux of the matter:
Code:
Sub emailReports()
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Const cstrMsgFileName As String = "e-mail text.html"
'// __booleans___________
Dim booIStartedOutlook As Boolean, _
booIOpenedDataWB As Boolean, _
booScrnUpdate As Boolean
'// __integers___________
Dim hndInput As Integer, i%, p&
'// __objects: outlook___
Dim appOL As Outlook.Application, _
emlNew As Outlook.MailItem, _
objRecipients As Outlook.Recipient
...
'// Create a Handle to Outlook
On Error Resume Next
Set appOL = Nothing
Set appOL = GetObject(, "Outlook.Application")
MsgBox "app is " & IIf((appOL Is Nothing), "", "NOT ") & "nothing.", vbInformation
On Error GoTo CleanUp
If appOL Is Nothing Then
booIStartedOutlook = True
Set appOL = New Outlook.Application
Else
booIStartedOutlook = False
End If
...
I have tried everything I can think of to get this to work and nothing is helping. I have
- Hacked the registry to give myself "total control" over the HKEY_CLASSES_ROOT folder.
- Hacked the registry to give myself the ability to register libraries. (Then, of course, I right-clicked the MSOUTL.OLB file and registered it.)
- Set a copy of the MSOUTL.OLB file in the C:\WINDOWS\SYSTEM and ...SYSTEM32 directories
- Shuffled the sequence of the references, moving the OUTLOOK reference up to #3, just below VBA & Excel.
- Confirmed that this library is registered.
- ...more that I've forgotten.
The only workaround was to change all the DIM statements to declare as generic OBJECTS. Then the code works just fine. But how the devil does one actually fix this? Like I said, the same code runs just fine on my old machine.
Last edited: