View Single Post
 
Old 05-29-2012, 09:12 AM
jackj22 jackj22 is offline Windows XP Office 2007
Novice
 
Join Date: Feb 2012
Location: SC
Posts: 6
jackj22 is on a distinguished road
Default

This was extremely helpful. Thank you!

Using this your sample code plus some others, I am able to successfully execute doing the following:
PHP Code:
Private Sub CommandButton1_Click()
Dim bStarted As Boolean
'Dim oOutlookApp As Outlook.Application
'
Dim oItem As Outlook.MailItem
' Check if Outlook is running.  If it is not, start Outlook
On Error Resume Next
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
    Set oOutlookApp = CreateObject("Outlook.Application")
    bStarted = True
End If
Set oItem = oOutlookApp.CreateItem(olMailItem)
  With oItem
    .Subject = "A/I: " & ActiveDocument.Name
    .Body = "<" & "File://" & ActiveDocument.FullName & ">"
    .To = "person1"
    .Cc = "the boss"
    .Importance = 2
    .Send
    '
.Display
  End With
'  Close Outlook if it was started by this macro.
If bStarted Then
    oOutlookApp.Quit
End If
'
Clean up
Set oItem 
NothingSet oOutlookApp Nothing

End Sub 
For some reason, I got a debug error on:
PHP Code:
'Dim oOutlookApp As Outlook.Application
'
Dim oItem As Outlook.MailItem 
..which is why I skip them. Any idea why? The code works fine as long as Outlook is open. For now, I've told my folks to make sure Outlook is open, otherwise it won't work.
Reply With Quote