Hello all,
Some background: I am running Win 7 Home Premium SP1 with 64-bit OS on a Dell Studio laptop.
For email I use Outlook 2007 since Windows Live Mail died and Outlook came with my Microsoft Office 2007.
With help I came up with VB macro code to duplicate the permanent delete done by using shift+delete then return. Basically I wanted a permanent delete button on the ribbon to make the operation one click. I learned that VB can't directly delete so you have to move the selected message(s) to a folder (in my case Perm Delete under the inbox) and then delete from there.
Here is my code but when I run it, I get Run Time Error #429 ActiveX component cannot create object on the line Set myOlApp = CreateObject("Outlook.Application").
Sub PermDelete()
Dim muOlApp, myNameSpace, Sel, objRecip As Object
Dim MyItem As Object
Dim MyItem1 As Outlook.MailItem
Dim PermDeleteFolder As Object
Dim objProperty As Object
Dim SavedEntryId, i
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set Sel = Application.ActiveExplorer.Selection
Set PermDeleteFolder = myNameSpace.GetDefaultFolder(olFolderInbox).Folder("Perm Delete")
For i = 1 To Sel.Count
If Sel.Item(i).Class = olMail Then
Set MyItem = Sel.Item(i)
MyItem.Move PermDeleteFolder
End If
Next
Dim obj As Object
For Each obj In PermDeleteFolder.Items
If DateDiff("N", obj.LastModificationTime, Now) < 1 / 1440 Then
obj.Delete
End If
Next
End Sub
I have searched here but only found referenced to Access which I do not believe is applicable to Outlook. Also web searches have suggested a lot of code fixes but after trying them I got the same result.
I am starting to believe something is missing in the Outlook install. I have run the Office repair from the original CD and that did not help.
Can someone point me in the right direction?
Thank you in advance fro your help!
Some background: I am running Win 7 Home Premium SP1 with 64-bit OS on a Dell Studio laptop.
For email I use Outlook 2007 since Windows Live Mail died and Outlook came with my Microsoft Office 2007.
With help I came up with VB macro code to duplicate the permanent delete done by using shift+delete then return. Basically I wanted a permanent delete button on the ribbon to make the operation one click. I learned that VB can't directly delete so you have to move the selected message(s) to a folder (in my case Perm Delete under the inbox) and then delete from there.
Here is my code but when I run it, I get Run Time Error #429 ActiveX component cannot create object on the line Set myOlApp = CreateObject("Outlook.Application").
Sub PermDelete()
Dim muOlApp, myNameSpace, Sel, objRecip As Object
Dim MyItem As Object
Dim MyItem1 As Outlook.MailItem
Dim PermDeleteFolder As Object
Dim objProperty As Object
Dim SavedEntryId, i
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set Sel = Application.ActiveExplorer.Selection
Set PermDeleteFolder = myNameSpace.GetDefaultFolder(olFolderInbox).Folder("Perm Delete")
For i = 1 To Sel.Count
If Sel.Item(i).Class = olMail Then
Set MyItem = Sel.Item(i)
MyItem.Move PermDeleteFolder
End If
Next
Dim obj As Object
For Each obj In PermDeleteFolder.Items
If DateDiff("N", obj.LastModificationTime, Now) < 1 / 1440 Then
obj.Delete
End If
Next
End Sub
I have searched here but only found referenced to Access which I do not believe is applicable to Outlook. Also web searches have suggested a lot of code fixes but after trying them I got the same result.
I am starting to believe something is missing in the Outlook install. I have run the Office repair from the original CD and that did not help.
Can someone point me in the right direction?
Thank you in advance fro your help!