Solved

outlook 2007 calendar

Posted on 2014-04-08
9
312 Views
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.
thanks
0
Comment
Question by:Basem Khawaja
  • 3
  • 3
  • 3
9 Comments
 
LVL 90

Expert Comment

by:John Hurst
Comment Utility
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.
0
 
LVL 13

Expert Comment

by:Chris Raisin
Comment Utility
Am looking into it via a macro.

Standy by.....
0
 

Author Comment

by:Basem Khawaja
Comment Utility
ok thanks every one
0
 

Author Comment

by:Basem Khawaja
Comment Utility
Mr. Hurst
what other style would allow me to accomplish my goal?
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 90

Accepted Solution

by:
John Hurst earned 500 total points
Comment Utility
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.
0
 
LVL 13

Expert Comment

by:Chris Raisin
Comment Utility
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.

http://pabweb.ru/32ch15g.shtml

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..

Cheers
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")
InputStart:
    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)
InputEnd:
    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)
  Else
    MsgBox "Please make sure a calendar view is currently displaying"
  End If
End Sub

Open in new window

0
 

Author Closing Comment

by:Basem Khawaja
Comment Utility
great guy
0
 
LVL 13

Expert Comment

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

Cheers
0
 
LVL 90

Expert Comment

by:John Hurst
Comment Utility
@basemkhawaja64 - Thank you and I was happy to help you.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
If you don't know how to downgrade, my instructions below should be helpful.
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.

771 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

10 Experts available now in Live!

Get 1:1 Help Now