Cannot close custom form in outlook 2007

  • Thread starter Thread starter njcooley
  • Start date Start date
N

njcooley

I am having trouble closing a custom form that I coded. It doesn't
matter if I use "Item.Close 0", "Item.Close(0)", or
"Item.getInspector.Close 0" I still have an Outlook closes improperly
error. All it does is generate an error report and then restarts
Outlook. Here's the code :

'Set a field equal to the user name
Function Item_Open()
Set myNameSpace = Application.GetNameSpace("MAPI")
Set Owner1 = UserProperties("RequestedBy")
If Owner1 = "" Then
Item.UserProperties.Find("RequestedBy").Value =
myNamespace.CurrentUser.Name
End If
End Function

' This processes the code when the Submit button is clicked
Function btnSubmit_Click()
If UserProperties("RequestedBy").Value = "" then
msgbox("You must enter your name in the Requested By field.")
Exit Function
End If
If UserProperties("FName").Value = "" then
msgbox("You must enter the Employee's name in the Full Name field.")
Exit Function
End If
If UserProperties("Loctn").Value = "" then
msgbox("You must enter the office location in the Location field.")
Exit Function
End If
If UserProperties("StrDt").Value = "None" then
msgbox("You must enter a start date in the Start Date field.")
ExitFunction
End If
Item_Write()
End Function

'Writes the email and checks what programs are needed
Function Item_Write()
On Error Resume Next
If UserProperties("Saved") = True then
Item.Save
Exit Function
End If

Dim ProgramList
Dim PrinterList
Dim MapDriveList
Dim OtherNotesList

PrinterList = "None"
MapDriveList = "None"
OtherNotesList = "None"

If UserProperties("Autodesk Civil3D") = True then
ProgramList = ProgramList & " Autodesk Civil3D, "
End If

If UserProperties("Autodesk Land Desktop") = True then
ProgramList = ProgramList & " Autodesk Land Desktop, "
End If

If UserProperties("Autodesk AutoCAD") = True then
ProgramList = ProgramList & " Autodesk AutoCAD, "
End If

If UserProperties("Microsoft Project") = True then
ProgramList = ProgramList & " Microsoft Project, "
End If

If UserProperties("Microsoft Publisher") = True then
ProgramList = ProgramList & " Microsoft Publisher, "
End If

If UserProperties("Adobe Acrobat Professional") = True then
ProgramList = ProgramList & " Adobe Acrobat Professional, "
End If

If UserProperties("Adobe Acrobat Standard") = True then
ProgramList = ProgramList & " Adobe Acrobat Standard, "
End If

If UserProperties("Microstation") = True then
ProgramList = ProgramList & " Microstaion, "
End If

If UserProperties("Staad") = True then
ProgramList = ProgramList & " Staad, "
End If

If UserProperties("RAMSteel") = True then
ProgramList = ProgramList & " RAMSteel, "
End If

If UserProperties("ArcView") = True then
ProgramList = ProgramList & " ArcView, "
End If

If UserProperties("OtherPrograms").Value <> "" then
ProgramList = ProgramList & UserProperties("OtherPrograms").Value +
"."
End If

If Right(ProgramList,2) = ", " then
ProgramList = Left(ProgramList, Len(ProgramList) - 2)
End If

If UserProperties("OtherPrinters").Value <> "" then
OtherPrinterList = UserProperties("OtherPrinters").Value
End If

If UserProperties("OtherDrives").Value <> "" then
MapDriveList = UserProperties("OtherDrives").Value
End If

If UserProperties("Other Notes").Value <> "" then
OtherNotesList = UserProperties("Other Notes").Value
End If

Set newEmployeeItem = Application.CreateItem(0)
Set myRecipients = newEmployeeItem.Recipients
myRecipients.Add("(e-mail address removed)")
'myRecipients.Add("(e-mail address removed)")
'myRecipients.Add("(e-mail address removed)")

'Writing the email
With newEmployeeItem
.Subject = "New employee " + UserProperties("FName").Value + "
setup information."
.HTMLBody = .HTMLBody + "</p><p style=""margin-top: 0; margin-
bottom: 0""><b>RequestedBy: </b>" +
UserProperties("RequestedBy").Value
.HTMLBody = .HTMLBody + "</p><p style=""margin-top: 0; margin-bottom:
0""><b>Employee Name: </b>" + CStr(UserProperties("FName").Value)
.HTMLBody = .HTMLBody + "</p><p style=""margin-top: 0; margin-
bottom: 0""><b>Start Date: </b>" + CStr(UserProperties("StrDt").Value)
.HTMLBody = .HTMLBody + "</p><p style=""margin-top: 0; margin-bottom:
0""><b>Location: </b>" + CStr(UserProperties("Loctn").Value)
.HTMLBody = .HTMLBody + "</p><p style=""margin-top: 0; margin-bottom:
0""><b>Programs needed:</b>" + CStr(ProgramList)
.HTMLBody = .HTMLBody + "</p><p style=""margin-top: 0; margin-
bottom: 0""><b>Additional printers needed: </b>" + CStr(PrinterList)
.HTMLBody = .HTMLBody + "</p><p style=""margin-top: 0; margin-bottom:
0""><b>Additional printers needed: </b>" + CStr(MapDriveList)
.HTMLBody = .HTMLBody + "</p><p style=""margin-top: 0; margin-bottom:
0""><b>Additional notes: </b>" + CStr(OtherNotesList)
.Send
End With
UserProperties("Saved").Value = True
Item_Close()
End Function
'Closes the form
Function Item_Close()
Item.getInspector.Close 0
End Function


Thanks for the help.
Nathaniel
 
It's still not working. The Save and Close button now works, but not
the line of code Item.Close or Item.GetInspector.Close
 
It's still not working. The Save andClosebutton now works, but not
the line of code Item.Closeor Item.GetInspector.Close

By the way, I'm using a command button in my form to do this operation.
 
am having trouble closing a custom form that I coded. It doesn't
matter if I use "Item.Close 0", "Item.Close(0)", or
"Item.getInspector.Close 0" I still have an Outlook closes improperly
error. All it does is generate an error report and then restarts
Outlook. Here's the code :

'Set a field equal to the user name
Function Item_Open()
Set myNameSpace = Application.GetNameSpace("MAPI")
Set Owner1 = UserProperties("RequestedBy")
If Owner1 = "" Then
Item.UserProperties.Find("RequestedBy").Value =
myNamespace.CurrentUser.Name
End If
End Function

' This processes the code when the Submit button is clicked
Function btnSubmit_Click()
If UserProperties("RequestedBy").Value = "" then
msgbox("You must enter your name in the Requested By field.")
Exit Function
End If
If UserProperties("FName").Value = "" then
msgbox("You must enter the Employee's name in the Full Name
field.")
Exit Function
End If
If UserProperties("Loctn").Value = "" then
msgbox("You must enter the office location in the Location
field.")
Exit Function
End If
If UserProperties("StrDt").Value = "None" then
msgbox("You must enter a start date in the Start Date field.")
ExitFunction
End If
Item_Write()
End Function

'Writes the email and checks what programs are needed
Function Item_Write()
On Error Resume Next
If UserProperties("Saved") = True then
Item.Save
Exit Function
End If

Dim ProgramList
Dim PrinterList
Dim MapDriveList
Dim OtherNotesList

PrinterList = "None"
MapDriveList = "None"
OtherNotesList = "None"

If UserProperties("Autodesk Civil3D") = True then
ProgramList = ProgramList & " Autodesk Civil3D, "
End If

If UserProperties("Autodesk Land Desktop") = True then
ProgramList = ProgramList & " Autodesk Land Desktop, "
End If

If UserProperties("Autodesk AutoCAD") = True then
ProgramList = ProgramList & " Autodesk AutoCAD, "
End If

If UserProperties("Microsoft Project") = True then
ProgramList = ProgramList & " Microsoft Project, "
End If

If UserProperties("Microsoft Publisher") = True then
ProgramList = ProgramList & " Microsoft Publisher, "
End If

If UserProperties("Adobe Acrobat Professional") = True then
ProgramList = ProgramList & " Adobe Acrobat Professional, "
End If

If UserProperties("Adobe Acrobat Standard") = True then
ProgramList = ProgramList & " Adobe Acrobat Standard, "
End If

If UserProperties("Microstation") = True then
ProgramList = ProgramList & " Microstaion, "
End If

If UserProperties("Staad") = True then
ProgramList = ProgramList & " Staad, "
End If

If UserProperties("RAMSteel") = True then
ProgramList = ProgramList & " RAMSteel, "
End If

If UserProperties("ArcView") = True then
ProgramList = ProgramList & " ArcView, "
End If

If UserProperties("OtherPrograms").Value <> "" then
ProgramList = ProgramList &
UserProperties("OtherPrograms").Value +
"."
End If

If Right(ProgramList,2) = ", " then
ProgramList = Left(ProgramList, Len(ProgramList) - 2)
End If

If UserProperties("OtherPrinters").Value <> "" then
OtherPrinterList = UserProperties("OtherPrinters").Value
End If

If UserProperties("OtherDrives").Value <> "" then
MapDriveList = UserProperties("OtherDrives").Value
End If

If UserProperties("Other Notes").Value <> "" then
OtherNotesList = UserProperties("Other Notes").Value
End If

Set newEmployeeItem = Application.CreateItem(0)
Set myRecipients = newEmployeeItem.Recipients

'Writing the email
With newEmployeeItem
.Subject = "New employee " + UserProperties("FName").Value + "
setup information."
.HTMLBody = .HTMLBody + "</p><p style=""margin-top: 0; margin-
bottom: 0""><b>RequestedBy: </b>" +
UserProperties("RequestedBy").Value
.HTMLBody = .HTMLBody + "</p><p style=""margin-top: 0; margin-
bottom:
0""><b>Employee Name: </b>" + CStr(UserProperties("FName").Value)
.HTMLBody = .HTMLBody + "</p><p style=""margin-top: 0; margin-
bottom: 0""><b>Start Date: </b>" + CStr(UserProperties("StrDt").Value)
.HTMLBody = .HTMLBody + "</p><p style=""margin-top: 0; margin-
bottom:
0""><b>Location: </b>" + CStr(UserProperties("Loctn").Value)
.HTMLBody = .HTMLBody + "</p><p style=""margin-top: 0; margin-
bottom:
0""><b>Programs needed:</b>" + CStr(ProgramList)
.HTMLBody = .HTMLBody + "</p><p style=""margin-top: 0; margin-
bottom: 0""><b>Additional printers needed: </b>" + CStr(PrinterList)
.HTMLBody = .HTMLBody + "</p><p style=""margin-top: 0; margin-
bottom:
0""><b>Additional printers needed: </b>" + CStr(MapDriveList)
.HTMLBody = .HTMLBody + "</p><p style=""margin-top: 0; margin-
bottom:
0""><b>Additional notes: </b>" + CStr(OtherNotesList)
.Send
End With
UserProperties("Saved").Value = True
Item_Close()
End Function
'Closes the form
Function Item_Close()
Item.getInspector.Close 0
End Function

Thanks for the help.
 
You can call Microsoft support and tell them you want the hotfixes described in the KB articles at http://support.microsoft.com/kb/937212/ and http://support.microsoft.com/kb/935517/ . Judging by the file version numbers, I think the April fix is the same as the April public update -- http://support.microsoft.com/kb/933493/ -- and is included in the May fix. If that's the case, then all you'll need is the May update, but you should ask to be sure.

FYI, there is a newsgroup specifically for Outlook forms issues "down the hall" at microsoft.public.outlook.program_forms or, via web interface, at http://www.microsoft.com/office/com...spx?dg=microsoft.public.outlook.program_forms
 

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

Back
Top