M
muyBN
I'm trying to send a message in Outlook that originates from a Word file but
I get the message that "ActiveX component can't create object" on the first
line of code from the following macro. (I am running Office 2003 and have the
most recent Outlook, Office and ActiveX object library references checked.)
Any suggestions would be greatly appreciated as I am using this as a job
search tool.
Sub SendFile()
…
Dim OLI As Outlook.Inspector, strAccountBtnName As String, intLoc As
Integer, blnStarted As Boolean
Dim CBs As Office.CommandBars, CBP As Office.CommandBarPopup, MC As
Office.CommandBarControl
Const ID_ACCOUNTS = 31224
Dim objOutlookApp As Outlook.Application, objItem As Outlook.MailItem
…
Set objOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set objOutlookApp = CreateObject("Outlook.Application")
blnStarted = True
End If
Set objItem = objOutlookApp.CreateItem(olMailItem)
'select account to send from (adapted from
http://www.outlookcode.com/codedetail.aspx?id=889)
Set OLI = objItem.GetInspector
If Not OLI Is Nothing Then
Set CBs = OLI.CommandBars
Set CBP = CBs.FindControl(, ID_ACCOUNTS)
If Not CBP Is Nothing Then
For Each MC In CBP.Controls
intLoc = InStr(MC.Caption, " ")
If intLoc > 0 Then
strAccountBtnName = Mid(MC.Caption, intLoc + 1)
Else
strAccountBtnName = MC.Caption
End If
'' If strAccountBtnName = AccountName Then
'' MC.Execute
'' Set_Account = AccountName
'' GoTo Exit_Function
'' End If
Next
End If
End If
…
Exit_Function:
Set MC = Nothing
Set CBP = Nothing
Set CBs = Nothing
Set OLI = Nothing
End Sub
I get the message that "ActiveX component can't create object" on the first
line of code from the following macro. (I am running Office 2003 and have the
most recent Outlook, Office and ActiveX object library references checked.)
Any suggestions would be greatly appreciated as I am using this as a job
search tool.
Sub SendFile()
…
Dim OLI As Outlook.Inspector, strAccountBtnName As String, intLoc As
Integer, blnStarted As Boolean
Dim CBs As Office.CommandBars, CBP As Office.CommandBarPopup, MC As
Office.CommandBarControl
Const ID_ACCOUNTS = 31224
Dim objOutlookApp As Outlook.Application, objItem As Outlook.MailItem
…
Set objOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set objOutlookApp = CreateObject("Outlook.Application")
blnStarted = True
End If
Set objItem = objOutlookApp.CreateItem(olMailItem)
'select account to send from (adapted from
http://www.outlookcode.com/codedetail.aspx?id=889)
Set OLI = objItem.GetInspector
If Not OLI Is Nothing Then
Set CBs = OLI.CommandBars
Set CBP = CBs.FindControl(, ID_ACCOUNTS)
If Not CBP Is Nothing Then
For Each MC In CBP.Controls
intLoc = InStr(MC.Caption, " ")
If intLoc > 0 Then
strAccountBtnName = Mid(MC.Caption, intLoc + 1)
Else
strAccountBtnName = MC.Caption
End If
'' If strAccountBtnName = AccountName Then
'' MC.Execute
'' Set_Account = AccountName
'' GoTo Exit_Function
'' End If
Next
End If
End If
…
Exit_Function:
Set MC = Nothing
Set CBP = Nothing
Set CBs = Nothing
Set OLI = Nothing
End Sub