G
Guest
I'm trying to develop a macro that will start a new email and copy a folder
name into the subject line. A friend wrote this short piece of code and I'm
not very well versed in VBA so I can't figure out why it stops. He claims it
works on his machine. Can someone help me tweak it? Do you need more
information? Thanks in advance,
Patrick
I get a run-time error "-2147023782 (8007045)':
Automation error
A dynamic link library (DLL) initialization routine failed.
Code in (General)
Public Sub Mail_Msg()
Dim FolderName As String
Dim oFolder As Outlook.MAPIFolder
Dim objOutlook As New Outlook.Application
Dim msg As Outlook.MailItem
Dim oNS As Outlook.NameSpace
Set oNS = Application.Session
Set def = oNS.PickFolder
Set oFolder = def
FolderName = oFolder.Name
Set msg = objOutlook.CreateItem(0) ***This is where it stops***
msg.Subject = FolderName
msg.Display
End Sub
name into the subject line. A friend wrote this short piece of code and I'm
not very well versed in VBA so I can't figure out why it stops. He claims it
works on his machine. Can someone help me tweak it? Do you need more
information? Thanks in advance,
Patrick
I get a run-time error "-2147023782 (8007045)':
Automation error
A dynamic link library (DLL) initialization routine failed.
Code in (General)
Public Sub Mail_Msg()
Dim FolderName As String
Dim oFolder As Outlook.MAPIFolder
Dim objOutlook As New Outlook.Application
Dim msg As Outlook.MailItem
Dim oNS As Outlook.NameSpace
Set oNS = Application.Session
Set def = oNS.PickFolder
Set oFolder = def
FolderName = oFolder.Name
Set msg = objOutlook.CreateItem(0) ***This is where it stops***
msg.Subject = FolderName
msg.Display
End Sub