Solved

Change a macro that opens everything to Handle Journal items

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

752 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