Re: Outlook object not being created by muyBN
muyBN
Mon Jun 26 21:00:02 CDT 2006
Sorry, I left that part out of the post. Here's the complete code:
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
Set OLI = M.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
Set_Account = ""
Exit_Function:
Set MC = Nothing
Set CBP = Nothing
Set CBs = Nothing
Set OLI = Nothing
...
--
Bryan
"Jezebel" wrote:
> Your code doesn't appear to create anything at all. You've declared the
> objects, but you also need to instantiate them --
>
> set objOutlookApp = Outlook.Application
>
> etc
>
>
>
>
> "muyBN" <muyBN@discussions.microsoft.com> wrote in message
> news:A53AE786-6E1D-4BA3-B229-556A8FD29A71@microsoft.com...
> > When I ran the following code the first couple of times it created the
> > object, but now it won't. My objective is to create an e-mail with
> > variables
> > defined previously in macro, and not sending it right away. Any
> > suggestions?
> > (The reference library Outlook item is check-boxed in the menu.)
> >
> > Dim objOutlookApp As Outlook.Application, objItem As Outlook.MailItem
> >
> > With objItem
> > .To = strEmail
> > .Subject = strCo & ", " & " " & strJ
> > .Body = "message"
> > .Display
> > End With
> > Selection.InsertFile FileName:=strNew, Range:="",
> > ConfirmConversions:=False,
> > Link:=False, Attachment:=True
> > Set objItem = Nothing
> > Set objOutlookApp = Nothing
> >
> > --
> > Bryan
>
>
>