Is Explorer.FolderSwitch the best event for hiding commandbarbutton?

  • Thread starter Thread starter tneslony
  • Start date Start date
T

tneslony

Greetings all,

I recently developed an outlook addin that adds a button to the
command bar. I need to hide this when not viewing emails. I took the
following strategy to do so:

Private Sub m_olExplorer_FolderSwitch()
Select Case m_olExplorer.CurrentFolder.Name
Case "Inbox"
objCommandBarButton.Visible = True
Case Else
objCommandBarButton.Visible = False
End Select
End Sub

The problem is that there is quite a bit of flicker (looks horrible).
The commandbar appears, then the Folderswitch event fires, then the
button is (re)enabled. It appears that everything else is occuring at
an earlier event... Any ideas?

-Tim
 
Hi Ken,

Thank you for your quick reply. I tried using the BeforeFolderSwitch
event, however I can't seem to figure out which folder will be
selected next. The m_olExplorer.CurrentFolder.Name returns (as one
would expect) the current folder.

Just to give you some background, I'm trying to hide or disable a
commandbarbutton when not viewing email (i.e. hide for calendar,
tasks, journal, etc...). Sorry if this a backwards method for
accomplishing this task. Can you suggest a better strategy?

PS: Thank you very much for sharing your VB6 template... It has made
learning Outlook programming a much more pleasant experience.

-Tim
 
And sorry for the double post... Didn't realize that I'd already done
so. I appreciate your support.

-Tim
 
The VB6 signature of that event is:

BeforeFolderSwitch(NewFolder As Object, Cancel As Boolean)

NewFolder is the MAPIFolder that will be switched to, so just use that.
NewFolder.Name will return the name of the new folder.

If you set Cancel = True that will prevent the switch from occurring. If you
set it False or don't touch it at all the switch will occur.




Hi Ken,

Thank you for your quick reply. I tried using the BeforeFolderSwitch
event, however I can't seem to figure out which folder will be
selected next. The m_olExplorer.CurrentFolder.Name returns (as one
would expect) the current folder.

Just to give you some background, I'm trying to hide or disable a
commandbarbutton when not viewing email (i.e. hide for calendar,
tasks, journal, etc...). Sorry if this a backwards method for
accomplishing this task. Can you suggest a better strategy?

PS: Thank you very much for sharing your VB6 template... It has made
learning Outlook programming a much more pleasant experience.

-Tim
 
Back
Top