Office 365
The VBA in word is used to send an email. The code is used with many computers with success, but for one in particular word freeze at the very beginning of the code when accessing the object model with CreateObject
. If Outlook is open it works fine but close it freeze, with the other computers it works fine in both cases.
Dim objOL As Object
Dim objEmailItem As Object
Set objOL = CreateObject("outlook.application") '*** Freezing ***
Set objEmailItem = objOL.createItem(varOlmailitem)
I tried uninstalling office and reinstalling it, stopping the antivirus, restarting.
Thanks.
CodePudding user response:
Try to use early binding, you first need to set a reference to the Outlook object library. Use the Reference command on the Visual Basic for Applications (VBA) Tools menu to set a reference to Microsoft Outlook xx.x Object Library, where xx.x represents the version of Outlook that you are working with. You can then use the following syntax to start an Outlook session.
Dim objOL as Outlook.Application
Set objOL = New Outlook.Application
See Automating Outlook from a Visual Basic Application for more information.