?
Solved

Change a macro that opens everything to Handle Journal items

Posted on 2008-06-19
3
Medium Priority
?
210 Views
Last Modified: 2010-04-21
The following macro does the following for all the items in a Folder

Opens the Item.
Waits a short while
and then Closes the item.

(I use this to speed up the updating of my google desktop database whenI move  my stuff from the server to loca user files)

The problem that I have right now is that I changed the behavior of Journal Items to open the actual Document instead of the journal item itself when clicking on them and when I run my macro it tries to open thousands of documents.


My question is how can I handl this in my macro?

I can either
change this behaviour at the begining of my macro
run the macro
and change this setting back to the way I need it at the end
OR check if it is a journal item and if so skip it

I need help on implementing either of these two solutions (preferrably the first) or any other idea that will handle my requirements.
Sub OpenAndCloseThemAll()
 
   On Error GoTo OpenAndCloseThemAll_Error
 
    ProcessFolder Application.ActiveExplorer.CurrentFolder
    MsgBox "All Done!", vbInformation + vbOKOnly, "Open And Close Them All Macro"
 
   On Error GoTo 0
   Exit Sub
 
OpenAndCloseThemAll_Error:

Open in new window

0
Comment
Question by:TOPIO
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 24

Expert Comment

by:purplepomegranite
ID: 21823685
I don't know of a way to change the behaviour of journal items programmatically.  I have just searched the Outlook Object Model, and there is nothing in there that helps with that.  It is possible that a registry setting may do it, but also probable that Outlook would require a restart each time a registry setting was changed to actually pick it up - so that probably wouldn't be a good solution.

It is straight-forward to check if an item is a journal item and then skip it.  Assuming you have an item i, this code will check what it is:

      If TypeName(i) = "JournalItem" Then ' if true, item is journal item

If you need help modifying your code, simply paste the relevant bit here and I can tell you what needs changing.
0
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 total points
ID: 21825630
Hi, TOPIO.

I modified part of the original code to skip folders containing journal items.  Simply replace the ProcessFolder sub-routine from the origianl question with the one below.  Give it a try and let me know if this solves the problem.
Sub ProcessFolder(olkFolder As Outlook.MAPIFolder)
    Dim olkSubFolder As Outlook.MAPIFolder, _
        olkMessage As Outlook.MailItem
    If olkFolder.DefaultItemType <> olJournalItem Then
        For Each olkMessage In olkFolder.Items
            olkMessage.Display
            olkMessage.Close olDiscard
        Next
    End If
    For Each olkSubFolder In olkFolder.Folders
        ProcessFolder olkSubFolder
    Next
    Set olkMessage = Nothing
    Set olkSubFolder = Nothing
End Sub

Open in new window

0
 
LVL 10

Author Closing Comment

by:TOPIO
ID: 31468841
great solution
0

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question