Explorer Wrapper Trouble

  • Thread starter Thread starter rauschy33
  • Start date Start date
R

rauschy33

Hello All,

I have been working the explorer wrapper concept from MicrosEye, but I
can't seem to get this to work. It seems that each time a new explorer is
opened and the explorer_activate module fires the new explorer will hang and
then die. In that module I have a refreshtoolbar module where I set a
reference to a custom toolbar and toolbar buttons and decide which button to
make visible etc. But when using the VB6 debugger it says in the
commandbars collection of the new explorer that my custom toolbar is not
there and the view and selection properties have errors saying "this
explorer has closed and cannot be used, please check your program and close
outlook". It seems that the toolbar and buttons that I created on the
initialize routine do not exist when I start a new explorer.

I have the toolbar and buttons set as not temporary, I wonder if I need
to create the toolbar and buttons each time a new explorer is created?

Please someone help this is driving me crazy.
 
Here is a few segments of my code. I appreciate any and all help, I am sure
it is something that I am doing wrong.

-------
Where my commandbar and buttons are created during intialization. This
routine is only called in the initialization routine I set up.
*** Note that I am setting my toolbar and buttons to Temporary
*** There are other subroutines that check and create the Commandbar and
buttons. If you need to see them I can post them.
-------
Friend Sub CreateOutlookItems(ByVal objExpl As Outlook.explorer)
' **** MUST create toolbars, buttons, menus, etc... within a class with
using a withevents type
On Error GoTo error_handler
Dim blnExists As Boolean

blnExists = IsCommandBarThere("PSShipCommandBar") 'Check to see if
commandbar exists
If Not blnExists Then 'If the toolbar does not exist create it
If loggingValue() Then LogFileWrite ("Creating PS|Ship Commandbar ")
Set CBPSSHip = CreateCommandBar(objExpl, "PSShipCommandBar",
msoBarTop, True)
Else
Set CBPSSHip = objExpl.CommandBars("PSShipCommandbar")
CBPSSHip.Delete
Set CBPSSHip = Nothing
Set CBPSSHip = CreateCommandBar(objExpl, "PSShipCommandBar",
msoBarTop, True)
'Set CBPSSHip = CreateCommandBar(objExpl, "PSShipCommandBar",
msoBarTop, False)
End If


If loggingValue() Then LogFileWrite ("Creating Fedex to Selected
Explorer Commandbar Button")
Set CBBselected = CreateAddInCommandBarButton(gStrProgId, "PS|Ship",
"PS-Ship Main Tag", _
"PS|Ship to Selected", 1757, True, msoButtonIconAndCaption,
"explorer", objExpl, Nothing, "pss_send.bmp", "PSShipCommandBar")

If loggingValue() Then LogFileWrite ("Creating PS-Ship Shipping Option
Menu Commandbar Button")
Set CBBShipMenu = CreateAddInCommandBarButton(gStrProgId, "PS|Ship
Menu", "PS-ShipMenu", _
"PS|Ship Menu", 1757, False, msoButtonIconAndCaption, "explorer",
objExpl, Nothing, "pss_menu.bmp", "PSShipCommandBar")

CBPSSHip.Visible = True

error_handler:
'MsgBox (Err.Number & " " & Err.Description)
If Err.Number <> 0 Then
Resume simple_exit
End If
simple_exit:
'MsgBox Err.Number & " " & Err.Description
'If LoggingValue() Then LogFileWrite ("***Error Occured in startProgram
module Number: " & Err.Number & " Description: " & Err.Description)
'If LoggingValue() Then LogFileWrite ("If Error Number is 0 means only
the program was canceled ")
Exit Sub

End Sub

-------------
Private Sub colExpl_NewExplorer(ByVal explorer As Outlook.explorer)
On Error Resume Next

gblnNewExpl = True
If loggingValue() Then LogFileWrite ("gblnNewExpl=" & gblnNewExpl & "
From colExpl_NewExplorer ")
If loggingValue() Then LogFileWrite ("Adding Explorer from
colExpl_NewExplorer Module")
AddExpl explorer
End Sub
-------------
Private Sub objOutlook_Startup()
On Error Resume Next
If loggingValue() Then LogFileWrite ("ColExpl.count=" &
colExpl.Count)
If colExpl.Count Then
If loggingValue() Then LogFileWrite ("Adding Explorer from
objOutlook_Startup Module")
AddExpl objOutlook.ActiveExplorer
End If
End Sub
------------




-------------------------
ExplWrap class
--------------------------
Option Explicit
Private gBaseClass As New clsMain
Private WithEvents m_objExpl As Outlook.explorer
Private m_nID As Integer

Private Sub Class_Initialize()
Set m_objExpl = Nothing
End Sub

Private Sub Class_Terminate()
Set m_objExpl = Nothing
End Sub

Public Property Let explorer(objExpl As Outlook.explorer)
Set m_objExpl = objExpl
End Property

Public Property Get explorer() As Outlook.explorer
Set explorer = m_objExpl
End Property

Public Property Let Key(anID As Integer)
m_nID = anID
End Property

Private Sub m_objExpl_Activate()
On Error Resume Next
Call RefreshToolBar(m_objExpl.CurrentFolder)

End Sub

Private Sub m_objExpl_BeforeFolderSwitch(ByVal NewFolder As Object, Cancel
As Boolean)
On Error Resume Next
If loggingValue Then LogFileWrite ("Explorer
BeforeFolderSwitch...Folder=" & NewFolder & "...Explorer=" & m_nID)
Call RefreshToolBar(NewFolder)

End Sub


Private Sub m_objExpl_Close()
On Error Resume Next
modOutlExpl.KillExpl m_nID, Me
Set m_objExpl = Nothing

If Outlook.Explorers.Count <= 1 Then
gBaseClass.UnInitHandler
End If
End Sub

Private Sub m_objExpl_FolderSwitch()

End Sub

Private Sub m_objExpl_SelectionChange()
On Error Resume Next
If loggingValue Then LogFileWrite ("ExplWrap Class SelectionChange
Module::gblnNewExpl = " & gblnNewExpl)
If gblnNewExpl Then
Call RefreshToolBar(m_objExpl.CurrentFolder)
gblnNewExpl = False
End If
End Sub

Public Sub RefreshToolBar(objFolder As Outlook.MAPIFolder)
' On Error GoTo errHandler

Dim objCBTemp As Office.CommandBar
Dim CBBselected As Office.CommandBarButton
Dim CBBShipMenu As Office.CommandBarButton

Set objCBTemp = m_objExpl.CommandBars("PSShipCommandBar")
If Err Then
If loggingValue Then LogFileWrite ("Module
RefreshToolBar::CommandBar PSShipCommandBar NOT Found")
'Toolbar does not exist
Else
If loggingValue Then LogFileWrite ("Module
RefreshToolBar::CommandBar PSShipCommandBar Found")
Set CBBselected = objCBTemp.FindControl(Tag:="PS-Ship Main Tag")
Set CBBShipMenu = objCBTemp.FindControl(Tag:="PS-ShipMenu")

If objFolder Is Nothing Then 'Handle file system folder
CBBselected.Visible = False
CBBShipMenu.Visible = True 'Always Visible

Else

CBBShipMenu.Visible = True ' Always Visible
Select Case objFolder.DefaultItemType
Case olContactItem
CBBselected.Visible = True
Case Else
CBBselected.Visible = False
End Select
End If

End If
End Sub



Ken Slovak - said:
Try posting some of your code so people can look it over and maybe see
what's wrong. I've been using Explorer wrappers for years without
those problems.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


rauschy33 said:
Hello All,

I have been working the explorer wrapper concept from MicrosEye, but I
can't seem to get this to work. It seems that each time a new explorer is
opened and the explorer_activate module fires the new explorer will hang and
then die. In that module I have a refreshtoolbar module where I set a
reference to a custom toolbar and toolbar buttons and decide which button to
make visible etc. But when using the VB6 debugger it says in the
commandbars collection of the new explorer that my custom toolbar is not
there and the view and selection properties have errors saying "this
explorer has closed and cannot be used, please check your program and close
outlook". It seems that the toolbar and buttons that I created on the
initialize routine do not exist when I start a new explorer.

I have the toolbar and buttons set as not temporary, I wonder if I need
to create the toolbar and buttons each time a new explorer is created?

Please someone help this is driving me crazy.
 
The only real difference I can see with how Randy has ItemsCB set up
is you are calling CreateOutlookItems with ByVal objExpl As
Outlook.Explorer and his CBOutlookItems(ByVal objFolder As
Outlook.MAPIFolder) uses a MAPIFolder argument.

Is your objExpl the ActiveExplorer? Your call to IsCommandBarThere
doesn't specify which Explorer to check and you aren't showing that
procedure. Could it be that IsCommandBarThere uses ActiveExplorer and
CreateOutlookItems might be looking at a different Explorer?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm
 
I'm not sure why you are crashing. What I would recommend is trying
ItemsCB as is, with no modifications. See if it crashes on your dev
machine the way your own code is crashing. If it doesn't then
something you are doing is different and you will have to track down
where the difference is and why it is causing your crashes.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm
 
Back
Top