Item_Open = False Causes Outlook to Abort

J

John Ford

I have a form with some scripting for the Item_Open event. When the
work is done, I want to "not open" the item, so I have Item_Open =
False just before the End Function for Item_Open.

This causes Outlook to abort, the kind that offers to send an error
report to MicroSoft.

Why/When can't I "not open" an item?

The "work" my Item_Open function does is to publish another form
(comes attached to the problematic form). Here's the code...

Function Item_Open()
If Item.Attachments.Count = 1 Then
Dim oFS 'As Scripting.FileSystemObject
Dim oForm 'As Outlook.MailItem
Dim oAtt ' As Outlook.Attachment
Dim sPath 'As String
Dim oFD 'As Outlook.FormDescription
Const olPersonalRegistry = 2
Const TemporaryFolder = 2
set oAtt = attachments(1)
Set oFS = CreateObject("Scripting.FileSystemObject")
sPath = oFS.GetSpecialFolder(TemporaryFolder).Path _
& "\" & oAtt.FileName
oAtt.SaveAsFile sPath
Set oForm = Application.CreateItemFromTemplate(sPath)
oFS.DeleteFile sPath
Set oFD = oForm.FormDescription
oFD.DisplayName = oAtt.DisplayName
oFD.PublishForm olPersonalRegistry
MsgBox oFD.DisplayName _
& " published to your Personal Forms Library"
Set oForm = Nothing
Set oFD = Nothing
Set oFS = Nothing
Item_Open = False End If
End Function ' <<<<< error happens after function end
 
J

John Ford

I actually had "Item.Close 1" originally, and got the error. I read up
on the Item_Open event, and decided that Item_Open = False was the
"correct" way to do it.

??????
-jcf

| Replace the
| Item_Open = False
| with
| item.close
|
| Take Advantage of Outlook,
| Walter
|
| >-----Original Message-----
| >I have a form with some scripting for the Item_Open
| event. When the
| >work is done, I want to "not open" the item, so I have
| Item_Open =
| >False just before the End Function for Item_Open.
| >
| >This causes Outlook to abort, the kind that offers to
| send an error
| >report to MicroSoft.
| >
| >Why/When can't I "not open" an item?
| >
| >The "work" my Item_Open function does is to publish
| another form
| >(comes attached to the problematic form). Here's the
| code...
| >
| >Function Item_Open()
| > If Item.Attachments.Count = 1 Then
| > Dim oFS 'As Scripting.FileSystemObject
| > Dim oForm 'As Outlook.MailItem
| > Dim oAtt ' As Outlook.Attachment
| > Dim sPath 'As String
| > Dim oFD 'As Outlook.FormDescription
| > Const olPersonalRegistry = 2
| > Const TemporaryFolder = 2
| > set oAtt = attachments(1)
| > Set oFS = CreateObject("Scripting.FileSystemObject")
| > sPath = oFS.GetSpecialFolder(TemporaryFolder).Path _
| > & "\" & oAtt.FileName
| > oAtt.SaveAsFile sPath
| > Set oForm = Application.CreateItemFromTemplate(sPath)
| > oFS.DeleteFile sPath
| > Set oFD = oForm.FormDescription
| > oFD.DisplayName = oAtt.DisplayName
| > oFD.PublishForm olPersonalRegistry
| > MsgBox oFD.DisplayName _
| > & " published to your Personal Forms Library"
| > Set oForm = Nothing
| > Set oFD = Nothing
| > Set oFS = Nothing
| > Item_Open = False End If
| >End Function ' <<<<< error happens after function
| end
| >
| >
| >.
| >
 

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