Search Folders Workaround OL2003

M

Max

I don't program so I hope I am not in the wrong place. I have done
research so don't switch off ;-) I have acute short term memory
problems and store everything in outlook that I can so I like to make
it as easy as possible to keep track of what I need to do and locate
data.

I want to achieve "Search Folders" that I can put in my shortcuts like
email but for Tasks and Calendar items. I want all my tasks in one
folder so I can add reminders to them which is not possibly by
splitting task folders which is where I am at now.

I have endlessly searched the internet on a way to create a search
folder on non email items.

In my wanderings I came across the possibility of using a saved
advanced search but they wont show up in my shortcuts and are not
really an indexed Search Folder.

I have found the Microsoft knowledge base item
http://support.microsoft.com/default.aspx?scid=kb;en-us;817890
and that shows promise but I could barley find any real life examples
of code for this on the internet and I am not up to the task of
writing macros, I could fill in the {insert details here} but that is
about it.

I know you can create and change views on folders and again that is
great and I can do that but again that does not fix my shortcut issue.

In summary the Search Folders are very good for what I want but
Microsoft just stopped short of making them fantastic.

Are there any pointers to more on this subject for an inexperienced
macro person?

Does anyone make a utility to do this in Outlook 2003 as I am prepared
to pay?

Thanks
 
K

Ken Slovak

Creating a search folder using code or a saved search won't help you at all
with what you want.

A search folder is a phantom folder. Nothing actually lives in a search
folder. All a search folder does is aggregate pointers to items that live in
other folders, where those items meet the criteria for the search folder.

So if you create a search folder for 10 Tasks folders all the items in those
folders would show up but reminders would only fire from items in the
default Tasks folder. In fact, the hidden Reminders folder that tracks
reminders is a search folder, set to search on items in Inbox, Contacts,
Tasks and Calendar for items with ReminderSet = True.

<shameless plug> Go to the link in my signature for information about
Outlook COM addins that let you get reminders from additional folders
</shameless plug>
 
M

Max

Thanks for the comprehensive reply Ken,
Creating a search folder using code or a saved search won't help you at
all with what you want.

A search folder is a phantom folder. Nothing actually lives in a search
folder. All a search folder does is aggregate pointers to items that live
in other folders, where those items meet the criteria for the search
folder.

[Ian] And that is how I understand it. It uses the advanced find and due to
the speed of opening the folder it must index the items.
So if you create a search folder for 10 Tasks folders all the items in
those folders would show up but reminders would only fire from items in
the default Tasks folder.

[Ian] Ok I must not have explained myself correctly or I don't understand
your reply. I currently have multiple task folders. I want to go to one task
folder but have a search folder to extract different views to put on my
shortcut bars. I want to get rid of the extra folders.
In fact, the hidden Reminders folder that tracks reminders is a search
folder, set to search on items in Inbox, Contacts, Tasks and Calendar for
items with ReminderSet = True.

[Ian] Hmm I did not think about that.
<shameless plug> Go to the link in my signature for information about
Outlook COM addins that let you get reminders from additional folders
</shameless plug>

[Ian] Hey I am happy to pay to get what I want. I am still interested in
moving to a single task folder and search folder hack to make search folders
using the advanced find format to show the single task folder in different
views on the shortcut navigation pane.
Even though this is for just my use I am happy to throw a few dollars if
someone could work this out.

Anyone know when the next BETA for outlook will be out? I am guessing that
search folders will be extended based on the fact that Microsoft show
workaround as it must be a faq.

Thanks for your fast response.

Ian
 
J

Jim Vierra

You can add a shortcut that is a saved search.

This works fine:
Sub AddShortcut()
Dim myOlApp As New Outlook.Application
Dim myOlBar As Outlook.OutlookBarPane
Dim myolGroup As Outlook.OutlookBarGroup
Dim myOlShortcuts As Outlook.OutlookBarShortcuts
Set myOlBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
Set myolGroup = myOlBar.Contents.Groups.Item(1)
Set myOlShortcuts = myolGroup.Shortcuts
myOlShortcuts.Add "file://c:\messages.oss", "My Search 2"
End Sub

As far as alerts go you might try using a piece of code to periodically scan
you tasks and generate allerts when they are ready. There is timer code
somewhere. I think on www.outlookcode.com If you can't find it I will send
it to you. A good way would be to create a collection filled with
references to task items that are within the alert period and refresh it
every 15 minute or whatever your minimum resolution would be. Use the saved
search to define the items to be monitored. Use the shortcut to quickly
access the items fo maintenance. The shortcut is dunamic and searches on
every click. Code could hide the search box for simplicity.

--
Jim Vierra
Max said:
Thanks for the comprehensive reply Ken,
Creating a search folder using code or a saved search won't help you at
all with what you want.

A search folder is a phantom folder. Nothing actually lives in a search
folder. All a search folder does is aggregate pointers to items that live
in other folders, where those items meet the criteria for the search
folder.

[Ian] And that is how I understand it. It uses the advanced find and due
to the speed of opening the folder it must index the items.
So if you create a search folder for 10 Tasks folders all the items in
those folders would show up but reminders would only fire from items in
the default Tasks folder.

[Ian] Ok I must not have explained myself correctly or I don't understand
your reply. I currently have multiple task folders. I want to go to one
task folder but have a search folder to extract different views to put on
my shortcut bars. I want to get rid of the extra folders.
In fact, the hidden Reminders folder that tracks reminders is a search
folder, set to search on items in Inbox, Contacts, Tasks and Calendar for
items with ReminderSet = True.

[Ian] Hmm I did not think about that.
<shameless plug> Go to the link in my signature for information about
Outlook COM addins that let you get reminders from additional folders
</shameless plug>

[Ian] Hey I am happy to pay to get what I want. I am still interested in
moving to a single task folder and search folder hack to make search
folders using the advanced find format to show the single task folder in
different views on the shortcut navigation pane.
Even though this is for just my use I am happy to throw a few dollars if
someone could work this out.

Anyone know when the next BETA for outlook will be out? I am guessing that
search folders will be extended based on the fact that Microsoft show
workaround as it must be a faq.

Thanks for your fast response.

Ian

 
M

Max

Thanks Jim,
This works fine:
Sub AddShortcut()
Dim myOlApp As New Outlook.Application
Dim myOlBar As Outlook.OutlookBarPane
Dim myolGroup As Outlook.OutlookBarGroup
Dim myOlShortcuts As Outlook.OutlookBarShortcuts
Set myOlBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
Set myolGroup = myOlBar.Contents.Groups.Item(1)
Set myOlShortcuts = myolGroup.Shortcuts
myOlShortcuts.Add "file://c:\messages.oss", "My Search 2"
End Sub

I know next to nothing about VBA but eventualy through googled and worked
out how to make the macro and then change the macro security levels so I
learnt something new today :) I got the search in the task bar but it is
still not the same as Microsoft was suggesting here
http://support.microsoft.com/default.aspx?scid=kb;en-us;817890 as a
workaround. I started fiddling around with the macro shown on the website
but very soon it was apparent that not only was I out of my depth but I was
drowning. I could not understand the url reference in the macro specificaly.
As far as alerts go you might try using a piece of code to periodically
scan you tasks and generate allerts when they are ready. There is timer
code somewhere.

Nah, I will buy Ken's software. As I said I don't mind paying if it works
and will refer people to software that does a task and is price effective.

So will the Microsoft example give me a real search folder or just a link to
an oss file like the above macro did? I am fussy, I want the same as the
email search folders. Anyone has an answer give me your paypal account and I
will put some money in as long as it works as specified and the price is
reasonable. Ken's pricing for his products are reasonable in my opinion but
as a custom one off it might be worth more. Maybe Ken can add to his utility
collection, eithe bundle it with one of the products or as a stand alone. I
don't mind learning but I realy am lost on the code Microsoft supply in the
link above :)

Thanks


I think on www.outlookcode.com If you can't find it I will send
it to you. A good way would be to create a collection filled with
references to task items that are within the alert period and refresh it
every 15 minute or whatever your minimum resolution would be. Use the
saved search to define the items to be monitored. Use the shortcut to
quickly access the items fo maintenance. The shortcut is dunamic and
searches on every click. Code could hide the search box for simplicity.

--
Jim Vierra
Max said:
Thanks for the comprehensive reply Ken,
Creating a search folder using code or a saved search won't help you at
all with what you want.

A search folder is a phantom folder. Nothing actually lives in a search
folder. All a search folder does is aggregate pointers to items that
live in other folders, where those items meet the criteria for the
search folder.

[Ian] And that is how I understand it. It uses the advanced find and due
to the speed of opening the folder it must index the items.
So if you create a search folder for 10 Tasks folders all the items in
those folders would show up but reminders would only fire from items in
the default Tasks folder.

[Ian] Ok I must not have explained myself correctly or I don't understand
your reply. I currently have multiple task folders. I want to go to one
task folder but have a search folder to extract different views to put on
my shortcut bars. I want to get rid of the extra folders.
In fact, the hidden Reminders folder that tracks reminders is a search
folder, set to search on items in Inbox, Contacts, Tasks and Calendar for
items with ReminderSet = True.

[Ian] Hmm I did not think about that.
<shameless plug> Go to the link in my signature for information about
Outlook COM addins that let you get reminders from additional folders
</shameless plug>

[Ian] Hey I am happy to pay to get what I want. I am still interested in
moving to a single task folder and search folder hack to make search
folders using the advanced find format to show the single task folder in
different views on the shortcut navigation pane.
Even though this is for just my use I am happy to throw a few dollars if
someone could work this out.

Anyone know when the next BETA for outlook will be out? I am guessing
that search folders will be extended based on the fact that Microsoft
show workaround as it must be a faq.

Thanks for your fast response.

Ian

I don't program so I hope I am not in the wrong place. I have done
research so don't switch off ;-) I have acute short term memory
problems and store everything in outlook that I can so I like to make
it as easy as possible to keep track of what I need to do and locate
data.

I want to achieve "Search Folders" that I can put in my shortcuts like
email but for Tasks and Calendar items. I want all my tasks in one
folder so I can add reminders to them which is not possibly by
splitting task folders which is where I am at now.

I have endlessly searched the internet on a way to create a search
folder on non email items.

In my wanderings I came across the possibility of using a saved
advanced search but they wont show up in my shortcuts and are not
really an indexed Search Folder.

I have found the Microsoft knowledge base item
http://support.microsoft.com/default.aspx?scid=kb;en-us;817890
and that shows promise but I could barley find any real life examples
of code for this on the internet and I am not up to the task of
writing macros, I could fill in the {insert details here} but that is
about it.

I know you can create and change views on folders and again that is
great and I can do that but again that does not fix my shortcut issue.

In summary the Search Folders are very good for what I want but
Microsoft just stopped short of making them fantastic.

Are there any pointers to more on this subject for an inexperienced
macro person?

Does anyone make a utility to do this in Outlook 2003 as I am prepared
to pay?

Thanks
 
K

Ken Slovak

That KB article you reference does create a search folder that is identical
to the search folders created in the UI, except that it can have folders
other than email folders. In fact, you can use that code as a basis for
creating a search folder that handles multiple types of folders (as long as
any properties you are using for a filter are available in all item types).

The property references use what's known as WEBDav syntax. Some properties
are documented in the Exchange SDK but the easiest way to see what to use as
a property tag is to create a custom view on a folder. If you do that and
get into the custom filter dialog you can see what to use. The technique is
to add the property and logical condition you want in the Advanced tab and
then go to the SQL tab to see what Outlook put in there as a property tag.

Some things you cannnot easily filter on that way (or at all) using the
Outlook object model. For example the property that determines whether an
item shows up as Read or Unread is actually only a bit (Boolean value) in a
property named PR_MESSAGE_FLAGS. You can't use Outlook code to get at it in
a search folder, you'd have to get real down and dirty and use Extended MAPI
to set up a search folder using that criteria in code.

Once you set up various search folders for a folder like Tasks you could set
up individual views on those search folders.

For tasks reminders are pretty easy. You have access to the ReminderSet and
ReminderTime fields. For contacts the problem is those fields aren't exposed
to you in the Outlook object model so you have to use undocumented property
tags and either CDO 1.21 or Extended MAPI or Redemption code to get at those
properties.
 
J

Jim Vierra

Max - Ken's right about the serch folders issue and my solution just creates
an easy to use custom search. I will not give you programmatic access but
will let you select groups of items and set common properties on the group.

Since I am not really clear on the exact outcome you are looking for perhaps
my suggestions aren't realy going in the right direction.

The Microsoft example creates a classic search folder with the sarch
subfolders attribute set.

A saved search works very much like a search folder except it is not dynamic
and must be excuted to refresh the contents. The added stength of a saved
search is that it can operate accross Folder stores.where "Search Folders"
can only work within on folder store and can't be searched themselves. As
you said - one cloud short of heaven.

Ken's software will do alot more and should be looked into. I believe you
can eval it for free before purchasing so it's a no brainer.
--
Jim Vierra
Max said:
Thanks Jim,
This works fine:
Sub AddShortcut()
Dim myOlApp As New Outlook.Application
Dim myOlBar As Outlook.OutlookBarPane
Dim myolGroup As Outlook.OutlookBarGroup
Dim myOlShortcuts As Outlook.OutlookBarShortcuts
Set myOlBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
Set myolGroup = myOlBar.Contents.Groups.Item(1)
Set myOlShortcuts = myolGroup.Shortcuts
myOlShortcuts.Add "file://c:\messages.oss", "My Search 2"
End Sub

I know next to nothing about VBA but eventualy through googled and worked
out how to make the macro and then change the macro security levels so I
learnt something new today :) I got the search in the task bar but it is
still not the same as Microsoft was suggesting here
http://support.microsoft.com/default.aspx?scid=kb;en-us;817890 as a
workaround. I started fiddling around with the macro shown on the website
but very soon it was apparent that not only was I out of my depth but I
was drowning. I could not understand the url reference in the macro
specificaly.
As far as alerts go you might try using a piece of code to periodically
scan you tasks and generate allerts when they are ready. There is timer
code somewhere.

Nah, I will buy Ken's software. As I said I don't mind paying if it works
and will refer people to software that does a task and is price effective.

So will the Microsoft example give me a real search folder or just a link
to an oss file like the above macro did? I am fussy, I want the same as
the email search folders. Anyone has an answer give me your paypal account
and I will put some money in as long as it works as specified and the
price is reasonable. Ken's pricing for his products are reasonable in my
opinion but as a custom one off it might be worth more. Maybe Ken can add
to his utility collection, eithe bundle it with one of the products or as
a stand alone. I don't mind learning but I realy am lost on the code
Microsoft supply in the link above :)

Thanks


I think on www.outlookcode.com If you can't find it I will send
it to you. A good way would be to create a collection filled with
references to task items that are within the alert period and refresh it
every 15 minute or whatever your minimum resolution would be. Use the
saved search to define the items to be monitored. Use the shortcut to
quickly access the items fo maintenance. The shortcut is dunamic and
searches on every click. Code could hide the search box for simplicity.

--
Jim Vierra
Max said:
Thanks for the comprehensive reply Ken,

Creating a search folder using code or a saved search won't help you at
all with what you want.

A search folder is a phantom folder. Nothing actually lives in a search
folder. All a search folder does is aggregate pointers to items that
live in other folders, where those items meet the criteria for the
search folder.

[Ian] And that is how I understand it. It uses the advanced find and due
to the speed of opening the folder it must index the items.

So if you create a search folder for 10 Tasks folders all the items in
those folders would show up but reminders would only fire from items in
the default Tasks folder.

[Ian] Ok I must not have explained myself correctly or I don't
understand your reply. I currently have multiple task folders. I want to
go to one task folder but have a search folder to extract different
views to put on my shortcut bars. I want to get rid of the extra
folders.

In fact, the hidden Reminders folder that tracks reminders is a search
folder, set to search on items in Inbox, Contacts, Tasks and Calendar
for items with ReminderSet = True.

[Ian] Hmm I did not think about that.

<shameless plug> Go to the link in my signature for information about
Outlook COM addins that let you get reminders from additional folders
</shameless plug>

[Ian] Hey I am happy to pay to get what I want. I am still interested in
moving to a single task folder and search folder hack to make search
folders using the advanced find format to show the single task folder in
different views on the shortcut navigation pane.
Even though this is for just my use I am happy to throw a few dollars if
someone could work this out.

Anyone know when the next BETA for outlook will be out? I am guessing
that search folders will be extended based on the fact that Microsoft
show workaround as it must be a faq.

Thanks for your fast response.

Ian






I don't program so I hope I am not in the wrong place. I have done
research so don't switch off ;-) I have acute short term memory
problems and store everything in outlook that I can so I like to make
it as easy as possible to keep track of what I need to do and locate
data.

I want to achieve "Search Folders" that I can put in my shortcuts like
email but for Tasks and Calendar items. I want all my tasks in one
folder so I can add reminders to them which is not possibly by
splitting task folders which is where I am at now.

I have endlessly searched the internet on a way to create a search
folder on non email items.

In my wanderings I came across the possibility of using a saved
advanced search but they wont show up in my shortcuts and are not
really an indexed Search Folder.

I have found the Microsoft knowledge base item
http://support.microsoft.com/default.aspx?scid=kb;en-us;817890
and that shows promise but I could barley find any real life examples
of code for this on the internet and I am not up to the task of
writing macros, I could fill in the {insert details here} but that is
about it.

I know you can create and change views on folders and again that is
great and I can do that but again that does not fix my shortcut issue.

In summary the Search Folders are very good for what I want but
Microsoft just stopped short of making them fantastic.

Are there any pointers to more on this subject for an inexperienced
macro person?

Does anyone make a utility to do this in Outlook 2003 as I am prepared
to pay?

Thanks
 
J

Jim Vierra

Ken - great - solved three problems

I never thought of using the filter builder SQL to feed the advaced search..

It also gets aroung the simplified syntax by using the full schema.

The one seeming restriction is that an search has to be confined to on
store. If I try to search multible folders in different PSTs I get an error
"one or more parameter values are incorrect" or "could not open the item"
Still I can use it by doing multiple concurrent searches.

This combined with a UserForm can provide a very simplified but powerful
search and item management form. We could even group items in a control by
type so setting properties on groups would be simpler. To gain dynamic
access we could add an HTML page to a folder and dump an HTML/XML report to
the page and refresh it every so often to make a highly customizable view of
items in Outlook/Exchange. All this for very little VBA and no CDO. Still
is much nicer to have the events.

Thanks Ken.
 
M

Max

Thats great guys but I think you missed the point I was making about being
out of me being out of my depth. I suggested there would be a big market for
someone to make search folders global. If not can someone just list the
Microsoft code and put an explanation on what things I would be puting
where?

I got the SQL and this is what I modified to search tasks overdue and due
today but I get a syntax error. Remember I don't know how to program, just
tinker.

Sub CreateNewSearchFolder()

Dim objSch As Search

'Create a folder that shows all tasks due and overdue
Dim strF As String
strF =
"http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/81050040"
<= 'today'

Dim strS As String
strS = "Tasks"

Dim strTag As String
strTag = "RecurSearch"

Set objSch = Application.AdvancedSearch(Scope:=strS, Filter:=strF, _
SearchSubFolders:=True, Tag:=strTag)

If objSch Is Nothing Then
MsgBox "Sorry, the search folder could not be created."
End If

objSch.Save ("MyTasks") 'Change MyTasks to the search folder you want to
create

End Sub
 
M

Max

I tried to run the Microsoft example and I thought that might work. I get
run time error unable to create folder. I was guessing the example would
work at least. If I had an example that worked that may help.

Thanks
 
K

Ken Slovak

Did you try to run the code within the Outlook VBA project? It worked with
no problems here.
 
K

Ken Slovak

Misplaced closing quote.

Change the line to this:
strF = _
"http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/81050040
_
<= 'today'"

Note that I put in continuation characters (a space before an underline) so
the line can wrap and still comprise one code line.

I'm not sure what you mean by "global" in the context of search folders. A
search folder can search any folder within a mail store (PST file or
Exchnage mailbox) but cannot search across different stores. It's impossible
due to the nature of how search folders are created and how they work.
 
K

Ken Slovak

That filter trick is a nice one, very easy to get the WEBDav guid for a
property. It's come in handy here many times.

By their nature search folders are restricted to searching only in one mail
store. And you can't create search folders for public folders stores in
Exchange. The reasons are rather arcane but involve where search folders are
created (in a hidden area under the RootFolder and then the Finder folders,
which doesn't exist in a public folders store and also how a MAPI
restriction or filter works, which is within one mail store only.

Until the day that Yukon finally rolls out and we have SQL Server based mail
stores that won't change since it would involve a complete re-engineering of
all of MAPI and how MAPI stores are created.
 
M

Max

Ok I still am not able to run without runtime error or I get can not create
folder.

It is a bit hard to copy and paste with the breaks in the newsgroup reader.

I am running it under tools > macros > visual basic editor. F5 to run.

I also tried tools > Macros > Macros > and Run it from there. There is only
one macro which I copied from the microsoft website.

Thanks
 
J

Jim Vierra

And you will get that erro if the folder already exists. Look in you search
folders and delete it if it exists then the error will go away. The check
for nothing doesn't detect the search foldeer until after you call the save
method then it throws the error. I did the same thing the first time and
had to look. I saw the folder was already there - I guess I used that name
in one of my other tests. Common name for things "My[Thing]".
 
M

Max

Thanks Jim,

I found the folder. I also found that the fields displayed were limited to
email ones so I guess the use is limited.

Now the big problem! is I closed outlook 2003 and now I can not get back in
as I assume the macro is trying to run. I get a dialog box with the
operation failed. I have spent a good hour looking on how to stop the macro
from running and found I need to rename this file VBAProject.OTM but it does
not exist. I assume Outlook 2003 uses a different file.

I have tried startup in safe mode but just can not get it going.

The hassle and time far outweighs the potential bennifits of getting search
folders working for tasks :)

Thanks

Jim Vierra said:
And you will get that erro if the folder already exists. Look in you
search folders and delete it if it exists then the error will go away.
The check for nothing doesn't detect the search foldeer until after you
call the save method then it throws the error. I did the same thing the
first time and had to look. I saw the folder was already there - I guess
I used that name in one of my other tests. Common name for things
"My[Thing]".
--
Jim Vierra
Ken Slovak said:
Misplaced closing quote.

Change the line to this:
strF = _
"http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/81050040
_
<= 'today'"

Note that I put in continuation characters (a space before an underline)
so the line can wrap and still comprise one code line.

I'm not sure what you mean by "global" in the context of search folders.
A search folder can search any folder within a mail store (PST file or
Exchnage mailbox) but cannot search across different stores. It's
impossible due to the nature of how search folders are created and how
they work.
 
M

Max

After reboots eventualy Outlook Started. Not sure what the problem was but
it had to be with messing around with the VBA.

Anyway would be interested in your comments on the limited fields in search
folders.

Now the big problem! is I closed outlook 2003 and now I can not get back
in as I assume the macro is trying to run. I get a dialog box with the
operation failed. I have spent a good hour looking on how to stop the
macro from running and found I need to rename this file VBAProject.OTM but
it does not exist. I assume Outlook 2003 uses a different file.

I have tried startup in safe mode but just can not get it going.

The hassle and time far outweighs the potential bennifits of getting
search folders working for tasks :)

Thanks

Jim Vierra said:
And you will get that erro if the folder already exists. Look in you
search folders and delete it if it exists then the error will go away.
The check for nothing doesn't detect the search foldeer until after you
call the save method then it throws the error. I did the same thing the
first time and had to look. I saw the folder was already there - I guess
I used that name in one of my other tests. Common name for things
"My[Thing]".
--
Jim Vierra
Ken Slovak said:
Misplaced closing quote.

Change the line to this:
strF = _
"http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/81050040
_
<= 'today'"

Note that I put in continuation characters (a space before an underline)
so the line can wrap and still comprise one code line.

I'm not sure what you mean by "global" in the context of search folders.
A search folder can search any folder within a mail store (PST file or
Exchnage mailbox) but cannot search across different stores. It's
impossible due to the nature of how search folders are created and how
they work.




Thats great guys but I think you missed the point I was making about
being out of me being out of my depth. I suggested there would be a big
market for someone to make search folders global. If not can someone
just list the Microsoft code and put an explanation on what things I
would be puting where?

I got the SQL and this is what I modified to search tasks overdue and
due today but I get a syntax error. Remember I don't know how to
program, just tinker.

Sub CreateNewSearchFolder()

Dim objSch As Search

'Create a folder that shows all tasks due and overdue
Dim strF As String
strF =
"http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/81050040"
<= 'today'

Dim strS As String
strS = "Tasks"

Dim strTag As String
strTag = "RecurSearch"

Set objSch = Application.AdvancedSearch(Scope:=strS, Filter:=strF, _
SearchSubFolders:=True, Tag:=strTag)

If objSch Is Nothing Then
MsgBox "Sorry, the search folder could not be created."
End If

objSch.Save ("MyTasks") 'Change MyTasks to the search folder you want
to create

End Sub
 
K

Ken Slovak

If you create a search folder for one type of item such as tasks you can use
any valid tasks property in your filter. If it's a mixed type search folder
you can only use properties that would be common to all the types of items
that could be in any one of those folders, such as Subject.
 
M

Max

If you create a search folder for one type of item such as tasks you can
use any valid tasks property in your filter. If it's a mixed type search
folder you can only use properties that would be common to all the types
of items that could be in any one of those folders, such as Subject.

Ok that makes sense but I have done a search using the sql of strF =
"urn:schemas:calendar:dtstart >= 'today'" and in the calendar view it shows
start / end date etc. In the search folder it shows the created date, size
etc which was not from the view at all. Of course I want the start date and
not the created date. How do I specifiy the fields to view as I guess the
sql is not able to do that? Thanks for all your help. I will download the
reminders software and send some money your way. I already use attachment
options and oops have not donated yet :) I must say you are very patient to
deal with an outlook user with next to no VBA experience in this forum. The
only surprise is that more people have not asked about search folders for
non email items. I did a lot of research before coming here with this
request.
 
K

Ken Slovak

That is the correct property for Start for an appointment item.

The view is something different. Even with search folders the view (in the
case of Outlook 2002 and 2003) can be modified by changing the XML for the
view for that folder. In the UI of course it's simple. You just select the
search folder and get into the custom view dialog. There you can set which
columns you want shown. You could event right-click on the column headers,
select Field Chooser and add any fields you want in whatever order you want.
While the Field Chooser is displayed you can just drag any columns off the
column header line to remove them from the view.

For coding a view it's much more complicated. The easiest way is to select
the search folder and in the Outlook VBA project run this procedure to see
the XML:

Sub FolderView()
Dim oFolder As Outlook.MAPIFolder
Dim oView As Outlook.View

Set oFolder = Application.ActiveExplorer.CurrentFolder
Set oView = oFolder.CurrentView
Debug.Print oView.XML

Set oView = Nothing
Set oFolder = Nothing
End Sub

That will show you the view XML in the Immediate window of the VBA project.
That can be selected and copied into a Notepad window and saved as
SFView.txt (or whatever name you want).

Then you can publish the view to the folder when it's created using code,
that would allow you to distribute your code and have any user of the code
have that view. If you want to see what publishing a view in code looks like
I can post some sample code.
 

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