Solved

Change a macro that opens everything to Handle Journal items

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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
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…

632 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