Solved

Change a macro that opens everything to Handle Journal items

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Find out how to use dynamic social media in email signatures with this top 10 DOs & DON’Ts.
Get an idea of what you should include in an email disclaimer with these Top 5 email disclaimer tips.
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now