Hi,
I have some VBA code that works well with Outlook 2010 but after upgrading to Outlook 2013 I cannot make it work. The below code does the following when it is run in Outlook 2010: 1) Reply to active email, 2) Remove Character # 74, 3) Clear Clipboard, 4) Select all, 5) Copy all, 6) Close email
Here's my code, any help converting to Outlook 2013 would be awesome!
Sub CopyAll_and_openSite()
Dim myinspector As Outlook.Inspector
Dim myItem As Outlook.MailItem
Dim Insp As Inspector
Dim obj As Object
Dim objApp
Dim objInsp
Dim colCB
Dim objCBB
On Error Resume Next
Set objApp = GetObject("", "Outlook.Application")
If objApp Is Nothing Then
Set objApp = Application.CreateObject("Outlook.Application")
End If
Set objInsp = objApp.ActiveInspector
If TypeName(objInsp) = "Nothing" Then
MsgBox "No inspector window found"
Exit Sub
Else
Set colCB = objInsp.CommandBars
Set objCBB = colCB.FindControl(, 354) ' Reply
objCBB.Execute
End If
Set obj = Nothing
Set Insp = Nothing
Set Insp = Application.ActiveInspector
Set obj = Insp.CurrentItem
obj.body = Replace(obj.body, Chr$(74), "") 'remove character 74
Set obj = Nothing
Set Insp = Nothing
Set objApp = GetObject("", "Outlook.Application")
If objApp Is Nothing Then
Set objApp = Application.CreateObject("Outlook.Application")
End If
Set objInsp = objApp.ActiveInspector
If TypeName(objInsp) = "Nothing" Then
MsgBox "No inspector window found"
Exit Sub
Else
Set colCB = objInsp.CommandBars
Set objCBB = colCB.FindControl(, 3634) ' clear clipboard
objCBB.Execute
Set objCBB = colCB.FindControl(, 756) ' select all
objCBB.Execute
Set objCBB = colCB.FindControl(, 19) ' copy
objCBB.Execute
Set myinspector = Application.ActiveInspector 'new
Set myItem = myinspector.CurrentItem 'new
myItem.Close olDiscard 'new
Set objCBB = colCB.FindControl(, 2011) ' Close email
objCBB.Execute
End If
Set myinspector = Application.ActiveInspector 'new
Set myItem = myinspector.CurrentItem 'new
myItem.Close olDiscard 'new
Set objCBB = Nothing
Set colCB = Nothing
Set objInsp = Nothing
End Sub
Thanks in advance,
Brent