Autoopen macro in outlook

  • Thread starter Thread starter Raymond
  • Start date Start date
R

Raymond

Hi

On the internet i've found this code with you heve to put in
thisoutlooksession so that users can't edit the outlookbar



VB:
--------------------------------------------------------------------------------
Dim WithEvents oPane As OutlookBarPane
Dim WithEvents oGroups As OutlookBarGroups
Dim WithEvents oShortcuts As OutlookBarShortcuts

Private Sub Application_Startup()
Set oPane = ActiveExplorer.Panes(1)
Set oGroups = oPane.Contents.Groups
Set oShortcuts = oPane.CurrentGroup.Shortcuts
End Sub

Private Sub oGroups_BeforeGroupAdd(Cancel As Boolean)
MsgBox "Sorry, you cannot add a group to the Outlook Bar."
Cancel = True
End Sub

Private Sub oGroups_BeforeGroupRemove _
(ByVal Group As OutlookBarGroup, Cancel As Boolean)
MsgBox "Sorry, you cannot remove a group from the Outlook Bar."
Cancel = True
End Sub

Private Sub oPanes_BeforeGroupSwitch _
(ByVal ToGroup As OutlookBarGroup, Cancel As Boolean)
Set oShortcuts = ToGroup.Shortcuts
End Sub

Private Sub oShortcuts_BeforeShortcutAdd(Cancel As Boolean)
MsgBox "Sorry, you cannot add a shortcut to the Outlook Bar."
Cancel = True
End Sub

Private Sub oShortcuts_BeforeShortcutRemove _
(ByVal Shortcut As OutlookBarShortcut, Cancel As Boolean)
MsgBox "Sorry, you cannot delete a shortcut from the Outlook
Bar."
Cancel = True
End Sub
--------------------------------------------------------------------------------



Because I want to show a VBA userform in outlook when a user opens a
mail item

I've add the fulling code


VB:
--------------------------------------------------------------------------------
Private Sub Application_Startup()
Set oPane = ActiveExplorer.Panes(1)
Set oGroups = oPane.Contents.Groups
Set oShortcuts = oPane.CurrentGroup.Shortcuts
Mailitem_Open
End Sub

Sub Mailitem_Open()
Dim test
If Mailitem.UnRead = False Then
myMsg = "Do you want to open this message again?"
If MsgBox(myMsg, 4) = 6 Then
test = True
MsgBox test
Else
test = False
MsgBox test
End If
End If
End Sub
--------------------------------------------------------------------------------



When I run this Code i get error 424. Can anyone tell why?

It's almost a function I've found in the help from visual basic. But
say that it's for VBScript.

Greetings Raymond
 
Where are you writing this code:
Is it in the scripting agent or in vba editor in outlook..?
Cheers

Adam
 
Back
Top