Application.ActiveInspector.CommandBars.FindControl(, 360) Type Mismatch

C

Carol Chisholm

This is related to an earlier post. (Thanks Ken for the help)
I want to open the next item in the inbox, starting at the currently
open item.

This code works when I have just started outlook, but sometimes gives
a "Error 13 Type Mismatch" on the Set olPop line.
It generally fails when I have been moving stuff around in the Inbox.

Dim oInbox As Outlook.MAPIFolder
Dim olApp As Application 'Outloook application
Dim olNameSpace As NameSpace

Set olApp = CreateObject("Outlook.Application")
Set olNameSpace = olApp.GetNamespace("MAPI")
Set oInbox = olNameSpace.GetDefaultFolder(olFolderInbox)
Set ActiveExplorer.CurrentFolder = oInbox
Set olPop = Application.ActiveInspector.CommandBars.FindControl(, 360)
Set olCmd = olPop.Controls(1)
 
K

Ken Slovak - [MVP - Outlook]

Are you positive that there actually is an ActiveInspector? There is one
only if at least one item has been opened. You can check for that by
counting the members of the Inspectors collection: Inspectors.Count.
 
C

Carol Chisholm

Hi Ken,

I have precisely one inspector, and it's name is "Outlook".
It has precisely one item in it, which has as caption the title of the
selected message.
The one item has 8 Command Bars
"Task Pane"
""
"Clipboard"
"Menu Bar"
"Standard"
"Form Design"
"Response"
"Formatting"

I guess the FindControl is looking through these 8 command bars to
find 360, and somehow fails, but I don't know why.
 
C

Carol Chisholm

Hi Ken,

I have precisely one inspector, and it's name is "Outlook".
It has precisely one item in it, which has as caption the title of the
selected message.
The one item has 8 Command Bars
"Task Pane"
""
"Clipboard"
"Menu Bar"
"Standard"
"Form Design"
"Response"
"Formatting"

I guess the FindControl is looking through these 8 command bars to
find 360, and somehow fails, but I don't know why.
 
C

Carol Chisholm

Hi Ken,

I have precisely one inspector, and it's name is "Outlook".
It has precisely one item in it, which has as caption the title of the
selected message.
The one item has 8 Command Bars
"Task Pane"
""
"Clipboard"
"Menu Bar"
"Standard"
"Form Design"
"Response"
"Formatting"

I guess the FindControl is looking through these 8 command bars to
find 360, and somehow fails, but I don't know why.
 
C

Carol Chisholm

Hi Ken,

I have precisely one inspector, and it's name is "Outlook".
It has precisely one item in it, which has as caption the title of the
selected message.
The one item has 8 Command Bars
"Task Pane"
""
"Clipboard"
"Menu Bar"
"Standard"
"Form Design"
"Response"
"Formatting"

I guess the FindControl is looking through these 8 command bars to
find 360, and somehow fails, but I don't know why.
 
C

Carol Chisholm

Hi Ken,

I have precisely one inspector, and it's name is "Outlook".
It has precisely one item in it, which has as caption the title of the
selected message.
The one item has 8 Command Bars
"Task Pane"
""
"Clipboard"
"Menu Bar"
"Standard"
"Form Design"
"Response"
"Formatting"

I guess the FindControl is looking through these 8 command bars to
find 360, and somehow fails, but I don't know why.
 
K

Ken Slovak - [MVP - Outlook]

I think you're confusing Inspectors and Explorers. Inspectors are the
objects used to display opened Outlook items (emails, tasks, contacts,
etc.). Explorers are used to display folder views. You only get an Inspector
if you open an item in code or the UI.

If you aren't confusing the 2 then I'm confused :)

In any search using FindControl I usually would enable the recursive setting
so the search digs down into each CommandBar object into all the top level
CommandBarControl objects as well as lower level ones.

FindControl(, 360, , , True)
 
C

CarolChi

My previous post is confusing.
I'm trying to move to the next item in the Inbox.
The code below works when Outlook is freshly opened.
The penultimate line returns a "type mismatch" when I have done anything
else in Outlook before I run the code on some computers.
I have also found that the error may be OS - specific, the error occurs
running in a TS session on Windows 2003 Server and when running on Vista beta
5219. It does not occur on plain vanilla XP. However as I have only tested on
three systems I can't be completely sure. This would explain the general
confusion.

Dim oInbox As Outlook.MAPIFolder
Dim olApp As Application
Dim olNameSpace As NameSpace

Set olApp = CreateObject("Outlook.Application")
Set olNameSpace = olApp.GetNamespace("MAPI")
Set oInbox = olNameSpace.GetDefaultFolder(olFolderInbox)
Set ActiveExplorer.CurrentFolder = oInbox

Set olPop = Application.ActiveInspector.CommandBars.FindControl(, 360)
Set olCmd = olPop.Controls(1)

Carol
 

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