【发布时间】:2020-07-13 19:22:54
【问题描述】:
我目前正在开发一个 access 2013 数据库。在其中一个表单上,我有一个收集信息的按钮,然后将其放入 Outlook 2013 电子邮件并发送。代码本身有效,但有时(我无法预测何时)我收到一个错误,显示为"run-time error '48', Error loading DLL"。一旦发生这种情况,我必须重新启动计算机才能使按钮再次工作。我只使用 VBA 几个星期,还没有找到解决此问题的方法。
-该程序(它是一个拆分数据库)所在的计算机上同时安装了 office 2010 和 2013。我不知道这是否是导致问题的原因,但我不知道当他们同时在电脑上时会发生什么以排除它。
-这个问题发生在程序的 .accde 和 .accdb 版本上
here is what the debugger shows when the error happens
'below is the code for the button that sends the email
Public Sub Command239_Click()
Dim oApp As Outlook.Application
Dim oMail As MailItem
Dim db As Database
'there is code a bunch of code between here that does not
'relate to sending the email
'accessing outlook
Set oApp = CreateObject("Outlook.application")
Set oMail = oApp.CreateItem(olMailItem) ' <<<<<<<<<<< this line is highlighted in yellow >>>>>>>>>>>>>>
'this is for the body of the email.
'things in quotes are text
'& between variables text and newlines
'type the variable to write its value
'vbCrLF goes to the next line
oMail.Body = "Incident Log: " & clsORopen & ", " & Lgst & ", " & Tme & vbCrLf & Division & ": " & Location & ", " & secLocation & vbCrLf & "Circuit/Apparatus: " & Circuit & vbCrLf & "Caused by: " & cause & ", " & rtcause & vbCrLf & vbCrLf & Disturbance & vbCrLf & vbCrLf & "Person Notified: " & Notified & vbCrLf & "Returned to Normal: " & Returned & vbCrLf & "User: " & getusername & " Date: " & Format(Now, "MMM,d,yyyy")
'the subject
oMail.Subject = Division & " - " & Tyype & ", " & Circuit
'sending to these people
oMail.To = emaillist
oMail.Send
Set oMail = Nothing
Set oApp = Nothing
【问题讨论】: