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
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