VB question (Reply, Select All, Copy, and close email)

B

BrentLaftin

Hi,

I'm trying to code Outlook to Reply, Select All, Copy, then close a
email. I can make the below code work perfectly if I don't have th
Reply code in the script, when I add the Reply code it stops working.

I'm using this code to quickly copy all contents of a selected email s
I can paste into a note record in my work system. I was also hoping t
add a line of dashes "------------------------------" between eac
individual email (header) but that's way above my head.

Any help would be greatly appreciated, here's the code I'm strugglin
with:

Sub CopyAll_and_openSite()
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

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 objCBB = colCB.FindControl(, 2011) ' Close email
objCBB.Execute

End If

Set objCBB = Nothing
Set colCB = Nothing
Set objInsp = Nothing
End Su
 
B

BrentLaftin

I was able to piece together a solution to this question and thought I'
post here in case anyone has a need:

Sub CopyAll_and_openSite()
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 objCBB = Nothing
Set colCB = Nothing
Set objInsp = 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 objCBB = colCB.FindControl(, 2011) ' Close email
objCBB.Execute

End If

Set objCBB = Nothing
Set colCB = Nothing
Set objInsp = Nothing

End Sub

Cheers,

Bren
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top