PC Review


Reply
Thread Tools Rate Thread

Cannot close custom form in outlook 2007

 
 
njcooley@gmail.com
Guest
Posts: n/a
 
      1st Jun 2007
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 Removed)")
'myRecipients.Add("(E-Mail Removed)")
'myRecipients.Add("(E-Mail 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

 
Reply With Quote
 
 
 
 
Roady [MVP]
Guest
Posts: n/a
 
      1st Jun 2007
Known issue. See;
http://support.microsoft.com/kb/937212

--
Robert Sparnaaij [MVP-Outlook]
Coauthor, Configuring Microsoft Outlook 2003
http://www.howto-outlook.com/
Outlook FAQ, HowTo, Downloads, Add-Ins and more

-----

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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 Removed)")
> 'myRecipients.Add("(E-Mail Removed)")
> 'myRecipients.Add("(E-Mail 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
>

 
Reply With Quote
 
njcooley@gmail.com
Guest
Posts: n/a
 
      1st Jun 2007
It's still not working. The Save and Close button now works, but not
the line of code Item.Close or Item.GetInspector.Close

 
Reply With Quote
 
njcooley@gmail.com
Guest
Posts: n/a
 
      1st Jun 2007
On Jun 1, 1:32 pm, njcoo...@gmail.com wrote:
> 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.

 
Reply With Quote
 
njcooley@gmail.com
Guest
Posts: n/a
 
      13th Jun 2007
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.


 
Reply With Quote
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      13th Jun 2007
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/comm....program_forms


--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


<(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Form - Outlook 2007 MMacauley Microsoft Outlook Discussion 0 2nd Apr 2009 02:58 PM
Outlook 2007 using custom form created for Outlook 2003 Jason Microsoft Outlook Program Addins 2 21st Mar 2009 06:29 AM
Create custom form in Outlook 2007 banato@yandex.ru Microsoft Outlook Form Programming 11 17th Oct 2008 06:43 PM
place .NET custom control on custom form in Outlook 2003 and Outlook 2007 sd Microsoft Outlook VBA Programming 7 11th Oct 2007 06:44 PM
Outlook 2007 - Error using Custom Form =?Utf-8?B?RXhUZXhhbg==?= Microsoft Outlook Discussion 2 16th Feb 2007 12:59 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:59 PM.