Solved

Change a macro that opens everything to Handle Journal items

Posted on 2008-06-19
3
204 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
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 500 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

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…
Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

803 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