|
-
Jun 10th, 2007, 10:32 PM
#1
Thread Starter
Lively Member
[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
-
Jun 11th, 2007, 04:34 AM
#2
Thread Starter
Lively Member
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...
-
Jun 11th, 2007, 10:41 PM
#3
Thread Starter
Lively Member
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 ...
-
Jun 12th, 2007, 02:33 AM
#4
Thread Starter
Lively Member
Re: Mission on Outlook Calendar
Erm...anybody there..?
Anybody free to answer my qns or any response ?
-
Jun 12th, 2007, 02:36 AM
#5
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 12th, 2007, 02:43 AM
#6
Thread Starter
Lively Member
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.
-
Jun 12th, 2007, 10:56 AM
#7
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 12th, 2007, 08:06 PM
#8
Thread Starter
Lively Member
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..?
-
Jun 12th, 2007, 08:52 PM
#9
Thread Starter
Lively Member
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...
-
Jun 12th, 2007, 09:35 PM
#10
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 12th, 2007, 09:40 PM
#11
Thread Starter
Lively Member
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...
-
Jun 12th, 2007, 10:32 PM
#12
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 12th, 2007, 10:47 PM
#13
Thread Starter
Lively Member
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 ?
-
Jun 12th, 2007, 11:00 PM
#14
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 12th, 2007, 11:15 PM
#15
Thread Starter
Lively Member
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?
-
Jun 13th, 2007, 01:22 AM
#16
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 13th, 2007, 01:30 AM
#17
Thread Starter
Lively Member
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.
-
Jun 13th, 2007, 01:38 AM
#18
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 13th, 2007, 02:31 AM
#19
Thread Starter
Lively Member
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?
-
Jun 13th, 2007, 02:48 AM
#20
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 13th, 2007, 02:52 AM
#21
Thread Starter
Lively Member
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:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim abc As New Microsoft.Office.Interop.Outlook.OlDefaultFolders
TextBox1.Text = abc.olFolderCalendar()
End Sub
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....
-
Jun 13th, 2007, 03:30 AM
#22
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:
Imports Outlook = Microsoft.Office.Interop.Outlook;
Public Class Form1
Private moApp As Outlook.Application
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim MyCalendar As Outlook.MAPIFolder
MyCalendar = moApp.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
'For demo as you should provide error handling for any items existing etc.
Textbox1.Text = MyCalendar.Items(1).Subject.ToString()
End Sub
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 13th, 2007, 04:07 AM
#23
Thread Starter
Lively Member
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.
-
Jun 13th, 2007, 07:47 AM
#24
Hyperactive Member
Re: Mission on Outlook Calendar
can you post the relevant code?
Thanks
-
Jun 13th, 2007, 09:32 AM
#25
Thread Starter
Lively Member
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.
-
Jun 13th, 2007, 10:08 AM
#26
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 13th, 2007, 07:41 PM
#27
Thread Starter
Lively Member
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?
-
Jun 13th, 2007, 09:56 PM
#28
Thread Starter
Lively Member
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:
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
MyCalendar = moApp.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
TextBox1.Text = MyCalendar.Items(1).start.ToString
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)
-
Jun 13th, 2007, 10:52 PM
#29
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:
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"""
sToday = sToday & " AND [Start] <= """ & DateTime.Today.ToShortDateString() & " 23:59:59"""
MyCalendar = moApp.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
MyItems = MyCalendar.Items.Restrict(sToday)
TextBox1.Text = MyItems.Count.ToString & " Items for Today" '?
'You can do this part: Loop through the items checking for if you should check the checkboxes or not.
End Sub
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 14th, 2007, 01:17 AM
#30
Thread Starter
Lively Member
Re: Mission on Outlook Calendar
I got an error after trying it out.
vb 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"""
sToday = sToday & " AND [Start] <= """ & DateTime.Today.ToShortDateString() & " 23:59:59"""
MyCalendar = moApp.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
TextBox1.Text = sToday
MyItems = MyCalendar.Items.Restrict(sToday)
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?
-
Jun 14th, 2007, 01:24 AM
#31
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 14th, 2007, 01:29 AM
#32
Thread Starter
Lively Member
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.
-
Jun 14th, 2007, 01:32 AM
#33
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 14th, 2007, 01:50 AM
#34
Thread Starter
Lively Member
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.
-
Jun 14th, 2007, 02:04 AM
#35
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 14th, 2007, 02:09 AM
#36
Thread Starter
Lively Member
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"
-
Jun 14th, 2007, 12:07 PM
#37
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 14th, 2007, 07:52 PM
#38
Thread Starter
Lively Member
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:
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'"
MyCalendar = moApp.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
Console.WriteLine(sToday)
MyItems = MyCalendar.Items.Restrict(sToday)
TextBox1.Text = MyItems.Count.ToString & " Items for Today" '?
End Sub
End Class
-
Jun 14th, 2007, 08:04 PM
#39
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 14th, 2007, 08:30 PM
#40
Thread Starter
Lively Member
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 ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|