I saw a similar thread, but my code below is a bit different. Any ideas appreciated.
It copies a Word doc into an Outlook email. The code below errors out at the .Active Inspector line.
Further below I paste a version that DOES work; however, it comes up with the Outlook security message, which is why I was trying to incorporate Redemption objects into the earlier version. How can I get the other code to work with Redemption?
___________________________________________________
'Errors out at .ActiveInspector. Adapted to add Redemption objects to bypass Outlook security msg. Base code from Sub SendDocAsMail()
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
'Start Outlook if it isn't running
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
End If
'Create a new message
Set oItem = oOutlookApp.CreateItem(olMailItem)
Set SafeItem = CreateObject("Redemption.SafeMailItem")
'Create an instance of Redemption.SafeMailItem
SafeItem.Item = olItem 'set Item property
'Copy the open document
Selection.WholeStory
Selection.Copy
Selection.End = True
'Set the WordEditor
Dim objinsp As Outlook.Inspector
Dim wdeditor As Word.Document
Set objinsp = SafeItem.GetInspector ' VS. oitem, safeitem
Set sInspector = CreateObject("Redemption.SafeINspector")
sInspector = objinsp
sInspector = Application.ActiveInspector
'sInspector.Item = Application.ActiveInspector
'Set wdeditor = sInspector.rtfeditor
Set wdeditor = objinsp.WordEditor
'Place the current document under the intro and signature
wdeditor.Characters(1).PasteAndFormat (wdFormatOriginalFormatting)
'sInspector.SelText
'Display the message
'oItem.Display
SafeItem.Display
'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
Set objinsp = Nothing
Set wdeditor = Nothing
End Sub
_______________________________________
'THIS VERSION WORKS but generates Outlook security msg
'base code from Sub SendDocAsMail()
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
'Start Outlook if it isn't running
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
End If
'Create a new message
Set oItem = oOutlookApp.CreateItem(olMailItem)
'Copy the open document
Selection.WholeStory
Selection.Copy
Selection.End = True
'Set the WordEditor
Dim objinsp As Outlook.Inspector
Dim wdeditor As Word.Document
Set objinsp = oItem.GetInspector ' VS. oitem, safeitem
'Set wdeditor = sInspector.rtfeditor
Set wdeditor = objinsp.WordEditor
'Place the current document under the intro and signature
wdeditor.Characters(1).PasteAndFormat (wdFormatOriginalFormatting)
'sInspector.SelText
'Display the message
oItem.Display
'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
Set objinsp = Nothing
Set wdeditor = Nothing
End Sub
It copies a Word doc into an Outlook email. The code below errors out at the .Active Inspector line.
Further below I paste a version that DOES work; however, it comes up with the Outlook security message, which is why I was trying to incorporate Redemption objects into the earlier version. How can I get the other code to work with Redemption?
___________________________________________________
'Errors out at .ActiveInspector. Adapted to add Redemption objects to bypass Outlook security msg. Base code from Sub SendDocAsMail()
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
'Start Outlook if it isn't running
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
End If
'Create a new message
Set oItem = oOutlookApp.CreateItem(olMailItem)
Set SafeItem = CreateObject("Redemption.SafeMailItem")
'Create an instance of Redemption.SafeMailItem
SafeItem.Item = olItem 'set Item property
'Copy the open document
Selection.WholeStory
Selection.Copy
Selection.End = True
'Set the WordEditor
Dim objinsp As Outlook.Inspector
Dim wdeditor As Word.Document
Set objinsp = SafeItem.GetInspector ' VS. oitem, safeitem
Set sInspector = CreateObject("Redemption.SafeINspector")
sInspector = objinsp
sInspector = Application.ActiveInspector
'sInspector.Item = Application.ActiveInspector
'Set wdeditor = sInspector.rtfeditor
Set wdeditor = objinsp.WordEditor
'Place the current document under the intro and signature
wdeditor.Characters(1).PasteAndFormat (wdFormatOriginalFormatting)
'sInspector.SelText
'Display the message
'oItem.Display
SafeItem.Display
'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
Set objinsp = Nothing
Set wdeditor = Nothing
End Sub
_______________________________________
'THIS VERSION WORKS but generates Outlook security msg
'base code from Sub SendDocAsMail()
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
'Start Outlook if it isn't running
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
End If
'Create a new message
Set oItem = oOutlookApp.CreateItem(olMailItem)
'Copy the open document
Selection.WholeStory
Selection.Copy
Selection.End = True
'Set the WordEditor
Dim objinsp As Outlook.Inspector
Dim wdeditor As Word.Document
Set objinsp = oItem.GetInspector ' VS. oitem, safeitem
'Set wdeditor = sInspector.rtfeditor
Set wdeditor = objinsp.WordEditor
'Place the current document under the intro and signature
wdeditor.Characters(1).PasteAndFormat (wdFormatOriginalFormatting)
'sInspector.SelText
'Display the message
oItem.Display
'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
Set objinsp = Nothing
Set wdeditor = Nothing
End Sub