refresh the currently selected item?

J

Jiho Han

I managed to create a macro that toggles the "Do Not AutoArchive" property
for a mailitem that is currently selected in the table view.
However, when the change doesn't get reflected until I move off the item.
Is there a way to refresh it to reflect the change that just occurred?

Thanks
Jiho
 
G

Guest

If you reapply the current view, it will refresh the property change:

Dim objMailItem As MailItem
Dim objItem As Object
Dim objView As Outlook.View

For Each objItem In ActiveExplorer.Selection
If objItem.Class = olmail Then
Set objMailItem = objItem
objMailItem.NoAging = True
End If
Set objView = ActiveExplorer.CurrentView
objView.Apply
Next

Set objMailItem = Nothing
Set objItem = Nothing
Set objView = Nothing
 
J

Jiho Han

Thanks for the sample code.
But it's not working for me. Now what is happening is that not only is the
change not reflected immediately, but it also creates and empty group Date:
(none) if I had selected the top row - my view is grouped by date. This
phenomenon seems visual only becase when I switch to another folder and come
back, everything is fine and the change has taken place properly as well.
Here's the code I am using (Outlook 2003) :

Private Sub ToggleDoNotAutoArchive()
If Application.ActiveExplorer.Selection.Count > 0 Then
Dim CurrentItem As Object
Set CurrentItem = Application.ActiveExplorer.Selection(1)
CurrentItem.NoAging = Not CurrentItem.NoAging
Application.ActiveExplorer.CurrentView.Apply
End If
End Sub
 
G

Guest

You're right, I ran my macro again and I saw the grouping by date behavior.
I ran the macro a few more times and it didn't do this again, but now the
value isn't getting refreshed. This worked the first time I wrote the macro!
Very strange.

You'll have to move to another folder and back or switch views and back;
these are the only ways I remember to force an update.
 
J

Jiho Han

Ok, thanks
You're right, I ran my macro again and I saw the grouping by date
behavior.
I ran the macro a few more times and it didn't do this again, but now
the
value isn't getting refreshed. This worked the first time I wrote the
macro!
Very strange.
You'll have to move to another folder and back or switch views and
back; these are the only ways I remember to force an update.
 

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