redirect or disable save button or file>save

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When the user clicks on Save button or File>Save, I'd like that another
function would be called or that the function would be disabled. how could I
do for both ?

this would be done in outlook, using VB6.

thanks for your answer.

pascal
 
To simplify you would have to handle the NewInspector event of the
Inspectors collection and wrap each new Inspector with a class module
that handled events for the items opened in that Inspector. Each item
type you wanted to handle would have a Save event that could be
trapped and your code in that event handler would do what you wanted
at that point.

This would not handle changes made to items in a folder view if
in-cell editing was enabled for that folder, you'd have to handle that
by setting up event handlers in a wrapper class for Explorer.Selection
and update that each time the folder or selection changed.

This should be done using an Outlook COM addin, so the first place to
start is by downloading the ItemsCB COM addin sample in VB6 code for a
look at an Explorer wrapper and the best practices for Outlook addins,
including workarounds for well-known Outlook COM addin bugs.

The Explorer wrapper can be used as a model for an Inspector wrapper.
I've also posted code for Inspector wrappers in this group in the past
and we've had many discussion threads in here about Inspector
wrappers. You can Google for some of that information using "Inspector
wrapper" as a search term.
 
it worked!
thanks for the tip.

Ken Slovak - said:
To simplify you would have to handle the NewInspector event of the
Inspectors collection and wrap each new Inspector with a class module
that handled events for the items opened in that Inspector. Each item
type you wanted to handle would have a Save event that could be
trapped and your code in that event handler would do what you wanted
at that point.

This would not handle changes made to items in a folder view if
in-cell editing was enabled for that folder, you'd have to handle that
by setting up event handlers in a wrapper class for Explorer.Selection
and update that each time the folder or selection changed.

This should be done using an Outlook COM addin, so the first place to
start is by downloading the ItemsCB COM addin sample in VB6 code for a
look at an Explorer wrapper and the best practices for Outlook addins,
including workarounds for well-known Outlook COM addin bugs.

The Explorer wrapper can be used as a model for an Inspector wrapper.
I've also posted code for Inspector wrappers in this group in the past
and we've had many discussion threads in here about Inspector
wrappers. You can Google for some of that information using "Inspector
wrapper" as a search term.
 
Hello Ken,

You are referring to the "Write" event right? I tried trapping that
event but it doesn't seem to get triggered although the documentation
says it should. Any ideas?

Thanks,
Zhen
 
Please post some of the preceding thread in your messages. That horrid
interface you are using to post doesn't do that and it makes it very hard to
follow a thread.

Depending on how the user closes the item or saves it Write may not fire.
You should trap Close as well as Write and set a Boolean if you handle
saving in one event so you don't handle it twice if both events do fire.
 
Hi Ken,

Sorry, I am using google to post directly :D

I am following the thread of pascal with regards to redirect or
disable the save function. here is your reply:

------------
To simplify you would have to handle the NewInspector event of the
Inspectors collection and wrap each new Inspector with a class module
that handled events for the items opened in that Inspector. Each item
type you wanted to handle would have a Save event that could be
trapped and your code in that event handler would do what you wanted
at that point.

This would not handle changes made to items in a folder view if
in-cell editing was enabled for that folder, you'd have to handle that
by setting up event handlers in a wrapper class for Explorer.Selection
and update that each time the folder or selection changed.

This should be done using an Outlook COM addin, so the first place to
start is by downloading the ItemsCB COM addin sample in VB6 code for a
look at an Explorer wrapper and the best practices for Outlook addins,
including workarounds for well-known Outlook COM addin bugs.

The Explorer wrapper can be used as a model for an Inspector wrapper.
I've also posted code for Inspector wrappers in this group in the past
and we've had many discussion threads in here about Inspector
wrappers. You can Google for some of that information using "Inspector
wrapper" as a search term.
----------------

I am trapping the SelectionChange Event of the explorer and placing
the selection in a Item Wrapper that traps the Write event, but I
found that saving the message directly from the explorer does not
trigger the Write event.

Basically, my code is something like.

private sub oExplorer_SelectionChange()
ItemContainer.clear
for i = 1 to oExplorer.Selection.count
ItemContainer.add(oExplorer.Selection(i))
next
end sub

and then in the ItemContainer.add method, I create a ItemWrapper
object for the item being added, the itemWrapper object handles the
Write event and sets cancel to true. however, when I try to save from
the explorer, the message still gets saved. I tried debugging and
found that the Write event handler was never called.

Thanks,
Zhen
 
The Write event won't fire if the user edits an item using in-cell editing
and changes that item. What you have to do to trap that is use an Items
event handler for the Items collection in the folder and handle the
ItemChange event. However that occurs after the change is already made to
the item and there is no Cancel argument in the ItemChange event.
 
Back
Top