rba*_*kam 7 ms-access outlook vba
我的任务是在 Microsoft Access 系统上修复 VB 中的一个问题,但我无法弄清楚。此问题仅发生在运行该软件的 5 台 PC 之一上。我试过了
Dim objOutlook As Outlook.Application
Dim objMailItem As MailItem
Dim db As DAO.Database
'Create email object and send attachment
Set objOutlook = DetectOutlook()
If objOutlook Is Nothing Then
Set objOutlook = New Outlook.Application
End If
Run Code Online (Sandbox Code Playgroud)
我尝试按照另一个网站上的建议将其更改为此。
Dim objOutlook As Object
Dim objMailItem As MailItem
Dim db As DAO.Database
'Create email object and send attachment
If GetObject(, "Outlook.Application") = True Then 'Outlook was already running
Set objOutlook = GetObject(, "Outlook.Application") 'Bind to existing instance of Outlook
Else 'Could not get instance of Outlook, so create a new one
Set objOutlook = New Outlook.Application
End If
Run Code Online (Sandbox Code Playgroud)
此代码更改最终迫使 Access 在运行时关闭。我是 VB 和 Access 开发的新手,所以也许这是一个简单的修复,如果您需要任何进一步的信息,请询问。其 2016 年微软仅供参考。先感谢您
您不妨尝试MSDN 上的 Dreadfool 建议的奇怪解决方法。它不需要您更改一行代码。
只需将宏保存到另一个文件中,然后将此新文件导入到您的项目中即可。当代码在 365 更新后停止工作时,这个简单的步骤对我有帮助。
小智 5
我怀疑问题是对不同 Outlook 版本的错误引用。
如果您的用户环境中可能使用不同版本的 Outlook 或 Access,则需要使用后期绑定。您发布的第二个代码已完成一半,但我建议您阅读此处;http://sourcedaddy.com/ms-access/late-binding.html