Error 48 - Error in Loading DLL

Lateral

Registered User.
Local time
Today, 14:55
Joined
Aug 28, 2013
Messages
388
Hi guys,

I have an error that I am having trouble tracking down.

I have a Microsoft 2007 environment (Word, Outlook and of course Access) running happily on a Windows 10 (Home edition) of a desktop PC.

I want to move the entire environment onto a laptop running Windows 10 (home edition).

I can install the Microsoft 2007 environment fine and it installs correctly. When I start my Access application it wall works well except when I close one of the forms that is automatically started as part of the startup routine. When I close this form, I get a pop up box with a title of :

Microsoft Office Access
Error 48 - Error in loading DLL.

I can start the offending form again and close it again but I don't get the message displayed again.....

I've checked the various Events for the form but can't seem to figure out what the issue is. I have reinstalled Office but the error still occurs.

I do not see this error on my Desktop environment.

Thanks for any help you can provide.

Cheers
Greg
 
As I read you post, it is only one particularly form that cause your problem, is that correct?
Do you've any code running in the form when you close it, (if yes, show the code)?
Try by creating a new form and copy all into it from the old one, (rename the old form to another name and the new one to the old form's name).
 
Check for missing references on your laptop.
Particularly if you have 32 bit on one pc and 64 bit on other
 
Hi Guys

Sorry for not replying sooner. I didn't receive any notification emails.

Anyway, here are my answers:

1. I have carefully checked the references on both PC's and they are exactly the same. Both PC's are running 64bit Windows 10 Home and the same 2007 environment.

2. I've done some more testing and I think I have found the offending code. It was in the On Current event of another form.

Here is the code:

Sub ImportFromOutlook()


On Error GoTo PROC_ERR

' This code is based in Microsoft Access.

' Set up DAO objects (uses existing "tblEmail" table)
Dim ol As New Outlook.Application
Dim olns As Outlook.Namespace
Dim cf As Outlook.MAPIFolder
Dim c As Outlook.MailItem
Dim objItems As Outlook.Items
Dim rstmessages, rstfiles As DAO.Recordset
Dim MyPath As String
Dim nummessages As Integer

Dim strCriteria As String



'open a couple of recordsets to handles emails and attachments
'Set rstmessages = CurrentDb.OpenRecordset("tblEmail")
Set rstfiles = CurrentDb.OpenRecordset("tblFileAttachments")

'grab the file path to the folder in which we will place attachments
MyPath = DLookup("[Folderpath]", "tlkplookup")

'check existence create if not
'If Not FolderExists(MyPath) Then
' If MsgBox("Do you want me to create the folder " & MyPath, vbYesNo + vbQuestion, "Create folder") = vbYes Then
' MkDir MyPath
' Else
' GoTo here:
' End If
'End If


'Delete the records from the tables

'CurrentDb.Execute "DELETE * FROM tblEmail", dbFailOnError
'CurrentDb.Execute "DELETE * FROM tblFileAttachments", dbFailOnError



' Set up Outlook objects.
Set olns = ol.GetNamespace("MAPI")

' Set the Inbox
'Set cf = olns.GetDefaultFolder(olFolderInbox)

'Set the Sent Folder
Set cf = olns.GetDefaultFolder(olFolderSentMail)

Set objItems = cf.Items

'Get the most recent date for a sent message already in the database
Set rstmessages = CurrentDb.OpenRecordset("SELECT MAX(SentDate) FROM tblEmail WHERE Folder = 'Sent'")

'If there is a most recent date, filter the list of message to exclude older ones
If Not rstmessages.EOF Then
If Not IsNull(rstmessages(0).value) Then
Set objItems = objItems.Restrict("[SentOn] > '" & Format(rstmessages(0).value, "ddddd h:nn AMPM") & "'")
End If
End If

nummessages = objItems.Count

If nummessages <> 0 Then

'Import the messages
For I = 1 To nummessages
'Forms!frmEmail.lblwarn.caption = "Processing Sent item " & I & " of " & nummessages
'Forms!frmEmail.Repaint

If TypeName(objItems(I)) = "MailItem" Then
Set c = objItems(I)
ProcessItem c, "Sent"
End If
Next I

End If

'Inbox
Set cf = olns.GetDefaultFolder(olFolderInbox)

Set objItems = cf.Items

'Get the most recent item date
Set rstmessages = CurrentDb.OpenRecordset("SELECT MAX(ReceivedTime) FROM tblEmail WHERE Folder = 'Inbox'")

'Filter the list to exclude old messages we should already have
If Not rstmessages.EOF Then
If Not IsNull(rstmessages(0).value) Then
Set objItems = objItems.Restrict("[ReceivedTime] > '" & Format(rstmessages(0).value, "ddddd h:nn AMPM") & "'")
End If
End If

nummessages = objItems.Count

If nummessages <> 0 Then

For I = 1 To nummessages
'Forms!frmEmail.lblwarn.caption = "Processing Inbox item " & I & " of " & nummessages
'Forms!frmEmail.Repaint

If TypeName(objItems(I)) = "MailItem" Then
Set c = objItems(I)
ProcessItem c, "Inbox"
End If
Next I

here:
'finished close the recordsets and cleanup
rstmessages.Close
rstfiles.Close
MyPath = ""
Set ol = Nothing
Set olns = Nothing
Set cf = Nothing
Set c = Nothing

Else

End If

Exit Sub

PROC_ERR:
MsgBox "Error " & Err.Number & " - " & Err.Description
'Resume PROC_EXIT

End Sub

It imports emails from the Inbox into a table.

This works fine on my desktop but I get the DLL error message when I run it on my Laptop.

Any ideas?

Cheers
Greg
 
Comment out the error handling, then post the code line in which you get the error.
 
Hi,

Here is the line of code that seems to be causing the issue:

Set olns = ol.GetNamspace("MAPI")
 
MAPI is the "Messaging" API.

Your code could be better formatted using the octothorpes (hash-tag marks) in the toolbar of the reply box. They put the special code markers around a section. But I've seen code like that before - here among other places - and was able to pick my way through it.

I notice you are dinking around with Outlook. There is an issue to be considered, and I don't see where your code addresses that issue correctly.

You can create multiple copies of Word or Excel and nobody barfs, although you DO need to remember to clean up after yourself. You can also manipulate single copies of Word or Excel to dink around with multiple files based on how you open documents or workbooks. But Outlook is INCREDIBLY picky.

I noted in your code that you have DIM'd a variable for the Outlook Application (using As New xxx syntax to create it) but you don't instantiate it properly (because of Outlook's special requirements). The recommendation is that you test for the existence of an active Outlook image with something like

Code:
    CreatedOL = FALSE
    On Error GoTo 0
    Set ol = GetObject( , "Outlook.Application" )
    If ol Is Nothing Then
        Set ol = CreateObject( "Outlook.Application" )
        CreatedOL = TRUE
    End If
    On Error GoTo <some error handler label>

I leave it to you to set up any flag (Y/N) variables you might need. The idea is, try to find an instance of Outlook. If that fails, create an instance of Outlook. Then a lot of those other things you want would be available. In keeping with the cleanup phase, if you created the instance of Outlook, you probably should destroy it. But if you merely found an extant instance and used it, you probably should leave it as-is.

I believe the behavior you describe is because you attempt to do something and it fails but the As New sequence triggers the launch of Outlook, and the second attempt might then succeed because now Outlook is open. Maybe.
 

Users who are viewing this thread

Back
Top Bottom