Use of m_blnOpenInsp in Item_Write() and Item_Close()

J

John E.

Sue,
I have made use of the approach you describe in section 18.3.1 of your book
in the code contained in all of our custom forms to prevent the user from
in-cell editing. It works for that purpose but as a result we are seeing
another anomaly in our folder based application which I cannot figure out how
to resolve.

Whenever we save an item by the "Save and Close" button, we can reopen it
normally and edit and save it again by the button. However, if we edit the
item after opening and then do a Save from the main menu and then later
attempt a Close from the menu, it pompts whether you want to save the item
and if you say Yes, it hangs up in the Write() function and displays the
Msgox "Please open the item to make changes" per your listing 18.12 in your
book. This doesn't make sense since the item is already open and also
indicates that somehow the variable m_blnOpenInsp is changing to False during
the Item_Write() or it wouldn't get to the MsgBox in the If statement. If
we also make some edits in the open item and then click the X box on upper
right of item form to create the close prompt that asks whether we want to
save the item or not, the same type of thing happens If you answer YES, it
gives the same MsgBox prompt and you can't save it...you HAVE to click the
close button and answer the prompt as NO without saving.

In either case, after you see the MsgBox prompt if you try to use the "Save
and Close" button the same thing happens and you HAVE to say NO to the prompt
and you can't salvage any of the edits you made.
Can you advise what we have to do to get the Close function to work normally
when using the menu Close item or the X box in the form without forcing the
If Not m_blnOpenInsp code in your Listing 18.12 which generates the MsgBox??

Here is our Item_Write() and Item_Close code and we do have m_blnOpenInsp
declared and set to True in Item_Open().
'------------------------------------------------------------------------------------------
Private Function Item_Write() 'See Mosher Listing 18.3 and FormControlsDemo
code
If Not m_blnOpenInsp Then
MsgBox "Please open the item to make changes."
Item_Write = False
End If
If Item.FullName = " " Then
Item_Write = False
MsgBox "Please fill in the form."
Else
Call StoreVisitList
Call StoreScreenButtons
End If
End Function
'------------------------------------------------------------------------------------------
Private Function Item_Close()
m_blnOpenInsp = False
'MsgBox "Form is closing"
Call StoreVisitList
Set m_lstVisitList = nothing
Set m_objExcel = Nothing
Set m_objWB = Nothing
Set m_objWS = Nothing
Set m_objRange = Nothing
Set m_blnIsNew = Nothing
Set m_objActiveFolder = Nothing
Set m_objPage = Nothing
Set m_intRowCount = Nothing
End Function
'-------------------------------------------------------------------------------------------
 
S

Sue Mosher [MVP-Outlook]

If you click Close, m_blnOpenInsp is set to False in the Item_Close event handler, before Write ever fires. You can comment out that statement, but I think that's only going to cause other problems if you reopen an item immediately after saving and closing it.

Because of such issues, I've pretty much given up on getting this technique to work. It didn't seem to be so problematic in Outlook 2000 and 2002, but the way Outlook caches items in later versions just doesn't seem to make it possible. I spent a couple of hours working on it yesterday, in fact, and came away with nothing but frustration.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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