outlook 2007 calendar

Posted on 2014-04-08
Last Modified: 2014-04-09
how do I print a time frame in outlook calendar i.e. 5/4/2014-6/28/2014 with out having the extra week showing 04/27/-5/3/2014 as the starting week and 6/29/14-7/5/2014 at the end.
Question by:Basem Khawaja
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
  • 3
  • 3
LVL 95

Expert Comment

by:John Hurst
ID: 39987765
If you print it as a monthly style, then I don't think you can do this:  Outlook 2007, 2010 and 2013. It just prints the month. It has always been thus for me and I cannot change that.
LVL 13

Expert Comment

by:Chris Raisin
ID: 39988104
Am looking into it via a macro.

Standy by.....

Author Comment

by:Basem Khawaja
ID: 39988783
ok thanks every one
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.


Author Comment

by:Basem Khawaja
ID: 39988785
Mr. Hurst
what other style would allow me to accomplish my goal?
LVL 95

Accepted Solution

John Hurst earned 500 total points
ID: 39988937
I have looked through various calendars. The Day, Week, Month styles are fixed and you cannot alter. There is (in Outlook 2013) a Calendar Details style that allows you to print any date range, but is a linear list and nothing that I can use.

So I use the monthly style (one page) and live with the dates.
LVL 13

Expert Comment

by:Chris Raisin
ID: 39989042
I have made some progress with a macro, and can obtain the data you are after, but cannot assign it back to the default views in outlook it seems. (only obtain a frsh set of items ready to be displayed). You COULD tweak the code to pprint out the items as a listing, but I think you are really after a "calendar" form, are you not?

There is a "work-around" (which involves quite a bit of work though), By incorporating a Microsoft View Control on a Userform within the macro you may be able to build your own view for display completely seperate from the stanfdard views supplied my Outlook (which are not flecible at all)..I am not sure whether you are "up" on all this techinical VBA stuff, so I do apologize if you are not.

If you are, though, have a look at the following link which gives detailed instructions on setting up a View Control within the macro.

The code I have written shows below. It finds the required items but I cannot refresh them back to the Outlook Calendar which is showing on your desktop.

A thought is that macro code code pass its info to the Microsoft View Control (as detailed in the article) and then produce the output, without you having to interact with the control itself.
It could be be incorporated into the working of the control (or you could in fact just interact with the control yourself to produce the view).

As it is, with the macro alone all you have to do is enter the start and end dates.
If we incorporate the ViewCtrl we could have the macro passing this info to the control and producing the output using the controls display functionality.

Alternatively you could simply interact directly with the control itself (messier).

It is quite a bit of work, and the initial code took me several hours. I am very tired now
(I am getting close to 65 years old now and sitting up after 2am is tiring) but if you want me to press on in developing the "ViewCtrl" or expand on the VBA code I have already written, I can do so but it may take several days.

Let me know what you think..

Chris (craisin)

Option Explicit

Public Sub CalendarView()
  'This module attempts to produce an extract of dates (a date range)
  'from the current outlook Calendar which is open, with the dates
  'enered by the operator as a start date and an end date.
  'Its aim is to produce a display of these calendar items in a view
  '(although this final stepo is still pending).
  'define variables and objects
  Dim myNameSpace As Outlook.NameSpace
  Dim oCalendar As Outlook.Folder
  Dim oView As Outlook.View
  Dim oItems As Outlook.Items
  Dim strStart As String
  Dim strEnd As String
  Dim dStart As Date
  Dim dEnd As Date
  Dim strFilter As String
  Dim objItem As Object
  Dim oItemsInDateRange As Outlook.Items

  'initialise various objects
  Set myNameSpace = Application.GetNamespace("MAPI")
  Set oCalendar = Application.Session.GetDefaultFolder(olFolderCalendar)
  Set oView = oCalendar.CurrentView
  Set oItems = oCalendar.Items
  'make sure the operator has a calendar view open
  If oView.ViewType = olCalendarView Then
    'there is error checking on the dates.
    'Note: You may need to tweak the code to agree with your localdate format
    '       e.g. Uk/Australia = "dd/mm/yyyy" whereas USA is "mm/dd/yyyy"
    'pick up the values used last time macro was run
    strStart = Format(GetSetting(Application.Name, "Setup", "CalendarViewStart", Now()), "dd/mm/yyyy")
    strEnd = Format(GetSetting(Application.Name, "Setup", "CalendarViewEnd", Now() + 31), "dd/mm/yyyy")
    On Error GoTo InputStart
    strStart = InputBox("Start date? (mm/dd/yyyy)", "Setup Calendar View", strStart)
    If Not IsDate(strStart) Then GoTo InputEnd
    dStart = CDate(strStart)
    On Error GoTo InputEnd
    strEnd = InputBox("End date? (mm/dd/yyyy)", "Setup Calendar View", strEnd)
    If Not IsDate(strEnd) Then GoTo InputEnd
    dEnd = CDate(strEnd)
    On Error GoTo 0
    If dEnd < dStart Then
      MsgBox "End date must follow start date"
      GoTo InputStart
    End If
    'save the current values for next run
    SaveSetting Application.Name, "Setup", "CalendarViewStart", dStart
    SaveSetting Application.Name, "Setup", "CalendarViewEnd", dEnd
    'Now the fun begins!
    'these items must be performed n this order and results in a collection of
    'calendar items that meet the date restrictions (sorted into dare order, oldest to latest)
    oItems.IncludeRecurrences = True  'we need to incororate recurring items otherwise something
                                      'sheculed for "Wednesday each week" would only show once!
    strFilter = "[Start] >= '" & _
          Format(dStart, "ddddd") & " 12:00 AM'" & _
          " AND [End] <= '" & _
          Format(dEnd, "ddddd") & " 11:59 PM'"
    'You must "find" the first item for the filter to "kick-in"
    Set objItem = oItems.Find(strFilter)
    'now we use "restrict" rather than "filter" since "restirct" is much faster!
    Set oItemsInDateRange = oItems.Restrict(strFilter)
    'Now we sort the items
    oItemsInDateRange.Sort "[Start]", False
    'we could list these items to the debug screen if we want (useless but proves we obtained the items)
    'instead we will just produce a little message saying how many items are in the collection just to
    'prove things work.
    MsgBox "Calendar Items found: " + CStr(oItemsInDateRange.Count)
    MsgBox "Please make sure a calendar view is currently displaying"
  End If
End Sub

Open in new window


Author Closing Comment

by:Basem Khawaja
ID: 39989247
great guy
LVL 13

Expert Comment

by:Chris Raisin
ID: 39989307
OK - It looks like you have accepeted someone else'scomment and you don't want me to go on with it....Good luck anyway.  :-)

LVL 95

Expert Comment

by:John Hurst
ID: 39989432
@basemkhawaja64 - Thank you and I was happy to help you.

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

An analysis of the phishing scam that has been affecting Google users, along with steps to take for protection, as well as what to do if you receive one of the emails.
In this step by step procedure, you will come to know the details of creating an Outlook meeting in 2007, 2010, 2013 & 2016.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

734 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