Page 1 of 3 123 LastLast
Results 1 to 40 of 106

Thread: [RESOLVED] Mission on Outlook Calendar

  1. #1

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Resolved [RESOLVED] Mission on Outlook Calendar

    Hi,

    A little short introduction of myself...
    I'm a newbie in programming.
    What I'm required to do is to open microsoft outlook calendar 2000 /2003 calendar and to extract those free time slot during "today" ( those time slot without appointment or events) using visual basic express edition or C# express edition without using microsoft exchange server.

    When i open the application , under which template should i choose ?
    (eg. Windows application , Class Library , Console Application , etc)

    P.S: There's alot of qns which is inside my mind which i hopefully you guys can help out because i'm really a starter to begin with...kindly bear with me with my qns...Thanks ~ ^.^

    Best Regards,
    ClaudeX

  2. #2

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Re: Mission on Outlook Calendar

    Hi,

    I did check with some of the forum that come across but i'm using visual basic studio 2005 / express edition 2005 or microsoft visual C# 2005 edition and it seem to be different in what u mention in the link (About How do I automate an Office App using VB 6? )...i'm not too sure i'm right or wrong .. VB is different from Visual basic studio 2005/ express edition right?

    sorry if i ask stupid qns...i'm really a newbie...

  3. #3

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Re: Mission on Outlook Calendar

    Hi,

    About the link to "http://vbforums.com/showthread.php?t=406639"
    Since i'm trying to get Outlook instead of excel , then will i need to change all Excel to Outlook and also add Outlook reference instead Excel reference
    Am i right?

    Since there is a "private void btnOpen_Click(object sender, System.EventArgs e)" in it..
    Then i will need to use Windows application so to have a form to create a button and name it as btnOpen ..am i correct?

    Sry ...too many qns to ask ...

  4. #4

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Re: Mission on Outlook Calendar

    Erm...anybody there..?

    Anybody free to answer my qns or any response ?

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Mission on Outlook Calendar

    Here is the link to the .NET C# automation example:
    http://vbforums.com/showthread.php?t=406639

    Its for Excel but similar for Outlook.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Unhappy Re: Mission on Outlook Calendar

    Oh...i have check it out and i copy and paste the code inside and replace all "Excel" to "Outlook" and also i add outlook reference instead of excel reference but there's still error going on..

    Under the sentence " using Outlook = Microsoft.Office.Interop.Outlook; " the office is been underline saying error..

    the error saying The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

    What does it mean and what's the solution for it?

    Erm...in the first place i also not sure whether i done it correctly a not...

    Thanks RobDog888 for replying ...
    Last edited by ClaudeX; Jun 12th, 2007 at 04:26 AM.

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Mission on Outlook Calendar

    No, you cant do a simple replacement of Excel with Outlook as their objects have different properties, methods etc.

    The underlining of Office means you probably dont have the Office PIAs installed. Check the link in my signature of how to install them.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Re: Mission on Outlook Calendar

    From what i search in the web....it explains that it require office 2003 in order to get it work... http://msdn2.microsoft.com/en-us/lib...ffice.11).aspx

    so i guess i have to get M.S office 2003 install in..?

  9. #9

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Re: Mission on Outlook Calendar

    I just installed M.S office 2003 ...and i try out your excel coding to test whether it will work ... but still i get error when running ...

    protected override void Dispose(bool disposing) ...it says 'WindowsApplication1.Form1.Dispose(bool)': no suitable method found to override

    and another 2 more error going on...

    kindly please help out...

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Mission on Outlook Calendar

    No, there are Office 2002 PIAs available but nothing earlier then that.

    Probably because the code is for VB.NET 2003 and what version are you running?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Re: Mission on Outlook Calendar

    I'm running C# 2005 Express edition version.
    I try out the early binding in your links http://www.vbforums.com/showthread.php?t=406639

    and get error from it...

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Mission on Outlook Calendar

    As noted in my code examples, the code is for .NET 2003 which is a different syntax then 2005.

    I have two examples so which are you using?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Re: Mission on Outlook Calendar

    I use the early binding which is the 2nd example... but since u mention it's 2003 and mine is 2005 then what should i do ?

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Mission on Outlook Calendar

    Open up a new C# project and add and name each control as shown in my code. Then add the events by clicking the button to select it and clicking the lightening bolt icon on the property window and doubleclicking the appropraite event. Then paste in just the events code from my example. Add the reference and public moApp object declaration etc. and your good to go.
    Last edited by RobDog888; Jun 13th, 2007 at 01:23 AM.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  15. #15

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Re: Mission on Outlook Calendar

    Wow....Thanks alot....
    Later i will go try it...because i going for lunch ...
    By the way ... there's a tool inside Outlook which is macro and under that section there is visual basic editor which look like some sort of programming like visual basic ...

    Can it be use for getting the data for free time slot as well?

  16. #16
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Mission on Outlook Calendar

    Yes, its the VBA (Visual Basic for Applications) IDE. It just depends on your apps needs if it can or should be done in VBA or outside of Outlook like with C# or VB.NET if you are providing a more robust app then what VBA can provide.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  17. #17

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Re: Mission on Outlook Calendar

    Do anybody have the code to display outlook calendar through microsoft visual basic studio 2005 ..?
    Just wanna try to see if it works for me...

    oh...i heard that VBA is different from Visual basic studio 2005 ... will it work out the same?
    Last edited by ClaudeX; Jun 13th, 2007 at 01:33 AM.

  18. #18
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Mission on Outlook Calendar

    Yes, its a completely different language.

    Give it a try and post where you may get stuck.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  19. #19

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Re: Mission on Outlook Calendar

    T.T

    I dun even know VB that well so i dun think i can do it for VBA...

    By the way ,right now i need to try to link the Visual basic studio 2005 with M.S outlook 2003, which i dun know how... any advise ?


    I got an error while trying to compile it....
    Dim abc As New Microsoft.Office.Interop.Outlook.OlDefaultFolders
    TextBox1.Text = abc.olFolderCalendar()

    Any idea what's is it and any solution to this?

  20. #20
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Mission on Outlook Calendar

    Post the rest of your code as it will make it easier.

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  21. #21

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Re: Mission on Outlook Calendar

    I use windows application template and double click it and go to form1.vb

    and here's the code
    vb Code:
    1. Public Class Form1
    2.  
    3.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.         Dim abc As New Microsoft.Office.Interop.Outlook.OlDefaultFolders
    5.         TextBox1.Text = abc.olFolderCalendar()
    6.     End Sub
    7. End Class

    i got add a reference of M.S outlook as well as M.S office library , but still end up getting that error....

  22. #22
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Mission on Outlook Calendar

    I thought you wanted it in C#?

    Well you are probably going to need a class level Outlook.Application object variable so all procedures can interact with Outlook.

    Then it looks like you are wanting to display something in a textbox but you can not do it that way. What is it to be displayed?


    vb Code:
    1. Imports Outlook = Microsoft.Office.Interop.Outlook;
    2.  
    3. Public Class Form1
    4.  
    5.     Private moApp As Outlook.Application
    6.  
    7.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    8.         Dim MyCalendar As Outlook.MAPIFolder
    9.         MyCalendar = moApp.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
    10.         'For demo as you should provide error handling for any items existing etc.
    11.         Textbox1.Text = MyCalendar.Items(1).Subject.ToString()
    12.     End Sub
    13. End Class
    Last edited by RobDog888; Jun 13th, 2007 at 03:34 AM.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  23. #23

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Re: Mission on Outlook Calendar

    I can use either C# or visual basic to do it... but it seems like visual basic is much more suitable in handling it so i guess i will stick to visual basic ...

    Erm..about the code, is it for displaying M.S outlook calendar?

    I try it out in VB and got some errors
    I add outlook and office library reference as always...

    Error1:'Imports' statements must precede any declarations.
    Error2:Type 'Outlook.Application' is not defined.
    Error3:Type 'Outlook.MAPIFolder' is not defined.
    Error4:Name 'Outlook' is not declared.

  24. #24
    Hyperactive Member r0k3t's Avatar
    Join Date
    Dec 2005
    Location
    Cleveland
    Posts
    361

    Re: Mission on Outlook Calendar

    can you post the relevant code?

    Thanks

  25. #25

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Re: Mission on Outlook Calendar

    I use the VB code given by RobDog888

    Any idea on solving it?
    Last edited by ClaudeX; Jun 13th, 2007 at 09:35 AM.

  26. #26
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Mission on Outlook Calendar

    Sounds like you didnt paste the code into your form otherwise it wouldnt generate the Imports error as it is the first line of coe in my example.

    Do you have the Interop installed?

    You can not just open/display the Calendar without just opening Outlook like you do manually. So what is it that you actually want?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  27. #27

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Re: Mission on Outlook Calendar

    Actually what i wanted is to have to able to display microsoft outlook 2003 calendar of the free time slot (meaning those time without appointment or events)

    Example: i have an appointment from 1pm to 3pm .. then it will display the rest of the time; "your available free time is from: 3pm to 11pm"

    But firstly i need to be able to link to my outlook right?

  28. #28

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Re: Mission on Outlook Calendar

    Thanks .. i was able to import after installing the Interop .
    Didn;t realise it was not installed in the first place. ^.^

    Now under as the design form , i created 23 checkbox, a monthly calendar,
    and a textbox.

    Using your code and i change the code to..
    vb Code:
    1. Imports Outlook = Microsoft.Office.Interop.Outlook
    2.  
    3. Public Class Form1
    4.     Private moApp As New Outlook.Application
    5.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    6.         Dim MyCalendar As Outlook.MAPIFolder
    7.         MyCalendar = moApp.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
    8.         TextBox1.Text = MyCalendar.Items(1).start.ToString
    9.     End Sub

    After i run ,the textbox display out the date and time.

    Right now what i wanted is that...
    1)It will only link to "today" time slot
    2)Those timing which is free and available will be checked ( those checkbox)

  29. #29
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Mission on Outlook Calendar

    Ok now we are getting somewhere knowing what you exactly need.

    The next step is to "filter" the .Items collection which is a collection of appointmentitems in the default calendar for a specific date/time range. Then loop through the filtered items and check the appropriate checkboxes.

    Im not sure what you want in the textbox1 control though.

    vb Code:
    1. Imports Outlook = Microsoft.Office.Interop.Outlook
    2.  
    3. Public Class Form1
    4.  
    5.     Private moApp As New Outlook.Application
    6.  
    7.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    8.  
    9.         Dim MyCalendar As Outlook.MAPIFolder
    10.         Dim MyItems As Outlook.Items
    11.         Dim sToday As String
    12.         sToday = "[Start] >= """ & DateTime.Today.ToShortDateString() & " 12:00:00"""
    13.         sToday = sToday & " AND [Start] <= """ & DateTime.Today.ToShortDateString() & " 23:59:59"""
    14.         MyCalendar = moApp.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
    15.         MyItems = MyCalendar.Items.Restrict(sToday)
    16.        
    17.         TextBox1.Text = MyItems.Count.ToString & " Items for Today" '?
    18.         'You can do this part: Loop through the items checking for if you should check the checkboxes or not.
    19.  
    20.     End Sub
    21.  
    22. End Class
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  30. #30

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Wink Re: Mission on Outlook Calendar

    I got an error after trying it out.


    vb Code:
    1. Imports Outlook = Microsoft.Office.Interop.Outlook
    2.  
    3. Public Class Form1
    4.     Private moApp As New Outlook.Application
    5.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    6.         Dim MyCalendar As Outlook.MAPIFolder
    7.         Dim MyItems As Outlook.Items
    8.         Dim sToday As String
    9.         sToday = "[Start] >= """ & DateTime.Today.ToShortDateString() & " 12:00:00"""
    10.         sToday = sToday & " AND [Start] <= """ & DateTime.Today.ToShortDateString() & " 23:59:59"""
    11.         MyCalendar = moApp.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
    12.         TextBox1.Text = sToday
    13.         MyItems = MyCalendar.Items.Restrict(sToday)
    14.         TextBox1.Text = MyItems.Count.ToString & " Items for Today"

    It can compile and run but it return to underlined codes(line 13) which says...

    MyItems = MyCalendar.Items.Restrict(sToday)

    COMException was unhandled
    Type Mismatch or the value "6/14/2007 12:00:00" in the condition is not valid.

    Any idea what does it mean and what's the solution for it?

  31. #31
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Mission on Outlook Calendar

    Ah sorry, was doing it from the reply box.

    Should be 12 hour time with AM/PM on it.

    " 12:00:00 AM"""

    and

    " 11:59:59 PM"""
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  32. #32

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Re: Mission on Outlook Calendar

    Oh ok...i put AM and PM like u say

    But still it return the same error saying

    COMException was unhandled
    Type mismatch or the value "6/14/2007 12:00:00 AM" in the condition is not valid.

  33. #33
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Mission on Outlook Calendar

    Do a console.writeline(sToday ) at line 10.5 and post the string.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  34. #34

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Re: Mission on Outlook Calendar

    You mean between the line 10 and 11, i add console.writeline(sToday )
    which will become ...

    Code:
    Imports Outlook = Microsoft.Office.Interop.Outlook
    
    Public Class Form1
        Private moApp As New Outlook.Application
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim MyCalendar As Outlook.MAPIFolder
            Dim MyItems As Outlook.Items
            Dim sToday As String
            sToday = "[Start] >= """ & DateTime.Today.ToShortDateString() & " 12:00:00 AM"""
            sToday = sToday & " AND [Start] <= """ & DateTime.Today.ToShortDateString() & " 23:59:59 PM"""
            Console.WriteLine(sToday)
            MyCalendar = moApp.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
            TextBox1.Text = sToday
            MyItems = MyCalendar.Items.Restrict(sToday)
            TextBox1.Text = MyItems.Count.ToString & " Items for Today"
        End Sub
    But then it return saying the same error.
    Last edited by ClaudeX; Jun 14th, 2007 at 01:53 AM.

  35. #35
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Mission on Outlook Calendar

    In your Output window (Ctl+Alt+O) and copy/paste its output in a post. I want to see the restrict string that is being passed.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  36. #36

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Re: Mission on Outlook Calendar

    ok.. here it is..

    [Start] >= "6/14/2007 12:00:00 AM" AND [Start] <= "6/14/2007 23:59:59 PM"

  37. #37
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Mission on Outlook Calendar

    Ah, ok now I remember. Its been a bit since I did restrictions.

    It should look like this...

    [Start] >= '6/14/2007 12:00:00 AM' AND [Start] <= '6/14/2007 23:59:59 PM'
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  38. #38

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Re: Mission on Outlook Calendar

    Ok...i modify it till i get the output that u want but then the Error is still there...

    vb Code:
    1. Imports Outlook = Microsoft.Office.Interop.Outlook
    2. Public Class Form1
    3.     Private moApp As New Outlook.Application
    4.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    5.         Dim MyCalendar As Outlook.MAPIFolder
    6.         Dim MyItems As Outlook.Items
    7.         Dim sToday As String
    8.         sToday = "[Start] >= '" & DateTime.Today.ToShortDateString() & " 12:00:00 AM'"
    9.         sToday = sToday & " AND [Start] <= '" & DateTime.Today.ToShortDateString() & " 23:59:59 PM'"
    10.         MyCalendar = moApp.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
    11.         Console.WriteLine(sToday)
    12.         MyItems = MyCalendar.Items.Restrict(sToday)
    13.         TextBox1.Text = MyItems.Count.ToString & " Items for Today" '?
    14.     End Sub
    15. End Class

  39. #39
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Mission on Outlook Calendar

    Ah! What is your date format? MM/DD/YYYY ?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  40. #40

    Thread Starter
    Lively Member ClaudeX's Avatar
    Join Date
    Jun 2007
    Posts
    66

    Re: Mission on Outlook Calendar

    You mean the outlook Calendar appointment start time format?
    Fri 6/15/2007

    But if i use #28, i was able to have this format display out........
    6/12/2007 12:00:00 PM

    So i suppose it should be MM/DD/YYYY ?

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width