Holidays import from Outlook

G

Guest

Hi, I need a holiday table in my database so I can use it to exclude any
public holidays when planning itineries. Due to the fact that we operate
throughout Europe the outlook.hol file which comes with Outlook would be
ideal as a basis. Has anyone used this as an import to Access? If so, I would
appreciate any help!

I did use it to add them all to an Exchange Public Folder and tried
importing this (File, Import from Access) but the table it produced excluded
the actual date of the holiday (appointment) which I found odd? It only had
dates for creation, last modified etc.

My coding skills are very basic so if anyone offer some advice it would be
most appreciated.

Thanks in advance for any help.
Sue
 
D

dan artuso

Hi,
It's just a text file so you can open it with Notepad and have a look at the
structure.
You would have to then decide how you want to store it in Access. I mean,
you probably wouldn't
want to just store the info all in one table as it would not be normalized.
 
G

Guest

Hi Dan,

Thanks for your reply, I know it is just a text file and what the structure
looks like - I just don't know how to read it into Access and was asking for
some assistance with that. I know the code for importing a text file but not
sure how to get all the right text into the relevant fields. I would like to
store the fields Country, HolidayTxt, Date based on the following structure.
How do I tell Access the Country is the bit in the brackers etc etc... ? I
don't want all the countries (eg US not required) but I can strip these out
manually first if necessary. I also wandered if anyone else had already
utilised this file in a similar manner and had some code for it?

[United Kingdom] 55
Battle of the Boyne (N. Ireland),2003/7/14
Boxing Day,2003/12/26
Christmas Day,2003/12/25

Thanks
Sue
 
D

Douglas J. Steele

It shouldn't be all that difficult to write code to read it.

Use the Line Input statement to read the text one line at a time.

Throw away blank lines.

If a line starts with [ and has ] somewhere later in it, determine what's in
between the brackets, and that's your current country. If you're interested
in holidays for that country, use the Split function on each of the
following rows to divide into the holiday name and date. You now know the
locale, holiday and date: you can insert into your table.

Continue untill the next country, or the end of the file.

Something like the following untested air-code:

Dim intFile As Integer
Dim intPos As Integer
Dim strCurrCountry As String
Dim strCurrLine As String
Dim strSQL As String
Dim varHolidayInformation As Variant

intFile = FreeFile()
Open "full path to file" For Input As #intFile

Do While Not Eof(intFile)
Line Input #intFile, strCurrLine
If Len(strCurrLine) > 0 Then
If Left$(strCurrLine, 1) = "["
intPos = InStr(2, strCurrLine, "]")
If intPos > 0 Then
strCurrCountry = Mid$(strCurrLine, 2, intPos - 2)
End If
Else
varHolidayInformation = Split(strCurrLine, ",")
If IsNull(varHolidayInformation) = False Then
strSQL = "INSERT INTO tblHoliday (Country, Holiday,
HolidayDt) " & _
"VALUES (" & Chr$(34) & strCurrCountry & Chr$(34) & ",
" & _
Chr$(34) & varHolidayInformation(0) & Chr$(34) & ", " &
_
CDate(varHolidayInformation(1) & ")"
CurrentDb.Execute strSQL, dbFailOnError
End If
End If
End If
Loop

Close #intFile

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



hughess7 said:
Hi Dan,

Thanks for your reply, I know it is just a text file and what the
structure
looks like - I just don't know how to read it into Access and was asking
for
some assistance with that. I know the code for importing a text file but
not
sure how to get all the right text into the relevant fields. I would like
to
store the fields Country, HolidayTxt, Date based on the following
structure.
How do I tell Access the Country is the bit in the brackers etc etc... ? I
don't want all the countries (eg US not required) but I can strip these
out
manually first if necessary. I also wandered if anyone else had already
utilised this file in a similar manner and had some code for it?

[United Kingdom] 55
Battle of the Boyne (N. Ireland),2003/7/14
Boxing Day,2003/12/26
Christmas Day,2003/12/25

Thanks
Sue


dan artuso said:
Hi,
It's just a text file so you can open it with Notepad and have a look at
the
structure.
You would have to then decide how you want to store it in Access. I mean,
you probably wouldn't
want to just store the info all in one table as it would not be
normalized.
 
G

Guest

Thanks very much Douglas, trying to get this working but a few probs. Can you
check the strsql statement please as the compiler wanted an extra ) at the
end so I had to modify to the following to get it to accept the code:

strSQL = "INSERT INTO tblHoliday (Country, Holiday,
HolidayDt)" & _
"VALUES (" & Chr$(34) & strCurrCountry & Chr$(34) & ","
& _
Chr$(34) & varHolidayInformation(0) & Chr$(34) & ", " & _
CDate(varHolidayInformation(1) & ")")

For some reason the country line does not read in correctly, access
interprets it as "ÿþ[United Kingdom] 55". Therefore the first If statements
are skipped and it reads this into the varholidayinformation. I then get an
run time error 9 on the strsql, subscript out of range.

I will try and replace the brackets [] with different characters and see if
this works...

Thanks
Sue



Douglas J. Steele said:
It shouldn't be all that difficult to write code to read it.

Use the Line Input statement to read the text one line at a time.

Throw away blank lines.

If a line starts with [ and has ] somewhere later in it, determine what's in
between the brackets, and that's your current country. If you're interested
in holidays for that country, use the Split function on each of the
following rows to divide into the holiday name and date. You now know the
locale, holiday and date: you can insert into your table.

Continue untill the next country, or the end of the file.

Something like the following untested air-code:

Dim intFile As Integer
Dim intPos As Integer
Dim strCurrCountry As String
Dim strCurrLine As String
Dim strSQL As String
Dim varHolidayInformation As Variant

intFile = FreeFile()
Open "full path to file" For Input As #intFile

Do While Not Eof(intFile)
Line Input #intFile, strCurrLine
If Len(strCurrLine) > 0 Then
If Left$(strCurrLine, 1) = "["
intPos = InStr(2, strCurrLine, "]")
If intPos > 0 Then
strCurrCountry = Mid$(strCurrLine, 2, intPos - 2)
End If
Else
varHolidayInformation = Split(strCurrLine, ",")
If IsNull(varHolidayInformation) = False Then
strSQL = "INSERT INTO tblHoliday (Country, Holiday,
HolidayDt) " & _
"VALUES (" & Chr$(34) & strCurrCountry & Chr$(34) & ",
" & _
Chr$(34) & varHolidayInformation(0) & Chr$(34) & ", " &
_
CDate(varHolidayInformation(1) & ")"
CurrentDb.Execute strSQL, dbFailOnError
End If
End If
End If
Loop

Close #intFile

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



hughess7 said:
Hi Dan,

Thanks for your reply, I know it is just a text file and what the
structure
looks like - I just don't know how to read it into Access and was asking
for
some assistance with that. I know the code for importing a text file but
not
sure how to get all the right text into the relevant fields. I would like
to
store the fields Country, HolidayTxt, Date based on the following
structure.
How do I tell Access the Country is the bit in the brackers etc etc... ? I
don't want all the countries (eg US not required) but I can strip these
out
manually first if necessary. I also wandered if anyone else had already
utilised this file in a similar manner and had some code for it?

[United Kingdom] 55
Battle of the Boyne (N. Ireland),2003/7/14
Boxing Day,2003/12/26
Christmas Day,2003/12/25

Thanks
Sue


dan artuso said:
Hi,
It's just a text file so you can open it with Notepad and have a look at
the
structure.
You would have to then decide how you want to store it in Access. I mean,
you probably wouldn't
want to just store the info all in one table as it would not be
normalized.

--

HTH
Dan Artuso, Access MVP



Hi, I need a holiday table in my database so I can use it to exclude
any
public holidays when planning itineries. Due to the fact that we
operate
throughout Europe the outlook.hol file which comes with Outlook would
be
ideal as a basis. Has anyone used this as an import to Access? If so, I
would
appreciate any help!

I did use it to add them all to an Exchange Public Folder and tried
importing this (File, Import from Access) but the table it produced
excluded
the actual date of the holiday (appointment) which I found odd? It only
had
dates for creation, last modified etc.

My coding skills are very basic so if anyone offer some advice it would
be
most appreciated.

Thanks in advance for any help.
Sue
 
G

Guest

I cut and paste just the uk section to a new text file and tested this as is,
it works now apart from the date. CDate line produced run time error 13 -
type mismatch. If I remove:
strSQL = "INSERT INTO tblHolidays (Country, Holiday,
HolidayDt)" & _
"VALUES (" & Chr$(34) & strCurrCountry & Chr$(34) & ","
& _
Chr$(34) & varHolidayInformation(0) & Chr$(34) & ", " & _
varHolidayInformation(1) & ")"

the table is populated but the dates are misinterpreted by access:

Country Holiday HolidayDt
United Kingdom Battle of the Boyne (N. Ireland) 19/01/1900 10:31:50
United Kingdom Battle of the Boyne (N. Ireland) 22/01/1900 20:34:17
United Kingdom Battle of the Boyne (N. Ireland) 22/01/1900 20:51:26
United Kingdom Battle of the Boyne (N. Ireland) 22/01/1900 21:08:34
United Kingdom Battle of the Boyne (N. Ireland) 22/01/1900 21:25:43
--
Thanks in advance for any help.
Sue


hughess7 said:
Thanks very much Douglas, trying to get this working but a few probs. Can you
check the strsql statement please as the compiler wanted an extra ) at the
end so I had to modify to the following to get it to accept the code:

strSQL = "INSERT INTO tblHoliday (Country, Holiday,
HolidayDt)" & _
"VALUES (" & Chr$(34) & strCurrCountry & Chr$(34) & ","
& _
Chr$(34) & varHolidayInformation(0) & Chr$(34) & ", " & _
CDate(varHolidayInformation(1) & ")")

For some reason the country line does not read in correctly, access
interprets it as "ÿþ[United Kingdom] 55". Therefore the first If statements
are skipped and it reads this into the varholidayinformation. I then get an
run time error 9 on the strsql, subscript out of range.

I will try and replace the brackets [] with different characters and see if
this works...

Thanks
Sue



Douglas J. Steele said:
It shouldn't be all that difficult to write code to read it.

Use the Line Input statement to read the text one line at a time.

Throw away blank lines.

If a line starts with [ and has ] somewhere later in it, determine what's in
between the brackets, and that's your current country. If you're interested
in holidays for that country, use the Split function on each of the
following rows to divide into the holiday name and date. You now know the
locale, holiday and date: you can insert into your table.

Continue untill the next country, or the end of the file.

Something like the following untested air-code:

Dim intFile As Integer
Dim intPos As Integer
Dim strCurrCountry As String
Dim strCurrLine As String
Dim strSQL As String
Dim varHolidayInformation As Variant

intFile = FreeFile()
Open "full path to file" For Input As #intFile

Do While Not Eof(intFile)
Line Input #intFile, strCurrLine
If Len(strCurrLine) > 0 Then
If Left$(strCurrLine, 1) = "["
intPos = InStr(2, strCurrLine, "]")
If intPos > 0 Then
strCurrCountry = Mid$(strCurrLine, 2, intPos - 2)
End If
Else
varHolidayInformation = Split(strCurrLine, ",")
If IsNull(varHolidayInformation) = False Then
strSQL = "INSERT INTO tblHoliday (Country, Holiday,
HolidayDt) " & _
"VALUES (" & Chr$(34) & strCurrCountry & Chr$(34) & ",
" & _
Chr$(34) & varHolidayInformation(0) & Chr$(34) & ", " &
_
CDate(varHolidayInformation(1) & ")"
CurrentDb.Execute strSQL, dbFailOnError
End If
End If
End If
Loop

Close #intFile

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



hughess7 said:
Hi Dan,

Thanks for your reply, I know it is just a text file and what the
structure
looks like - I just don't know how to read it into Access and was asking
for
some assistance with that. I know the code for importing a text file but
not
sure how to get all the right text into the relevant fields. I would like
to
store the fields Country, HolidayTxt, Date based on the following
structure.
How do I tell Access the Country is the bit in the brackers etc etc... ? I
don't want all the countries (eg US not required) but I can strip these
out
manually first if necessary. I also wandered if anyone else had already
utilised this file in a similar manner and had some code for it?

[United Kingdom] 55
Battle of the Boyne (N. Ireland),2003/7/14
Boxing Day,2003/12/26
Christmas Day,2003/12/25

Thanks
Sue


:

Hi,
It's just a text file so you can open it with Notepad and have a look at
the
structure.
You would have to then decide how you want to store it in Access. I mean,
you probably wouldn't
want to just store the info all in one table as it would not be
normalized.

--

HTH
Dan Artuso, Access MVP



Hi, I need a holiday table in my database so I can use it to exclude
any
public holidays when planning itineries. Due to the fact that we
operate
throughout Europe the outlook.hol file which comes with Outlook would
be
ideal as a basis. Has anyone used this as an import to Access? If so, I
would
appreciate any help!

I did use it to add them all to an Exchange Public Folder and tried
importing this (File, Import from Access) but the table it produced
excluded
the actual date of the holiday (appointment) which I found odd? It only
had
dates for creation, last modified etc.

My coding skills are very basic so if anyone offer some advice it would
be
most appreciated.

Thanks in advance for any help.
Sue
 
G

Guest

Wahey, finally cracked it!

Dim ConvertDate as Date
ConvertDate = varHolidayInformation(1)
HolDate = "#" & Format$(ConvertDate, "mm\/dd\/yyyy") & "#"
strSQL = "INSERT INTO tblHolidays (Country, Holiday,
HolidayDt)" & _
"VALUES (" & Chr$(34) & strCurrCountry & Chr$(34) & ","
& _
Chr$(34) & varHolidayInformation(0) & Chr$(34) & "," &
HolDate & ")"

DOUG - THANKS A MILLION for the code, couldn't have done it without you!

hughess7 said:
I cut and paste just the uk section to a new text file and tested this as is,
it works now apart from the date. CDate line produced run time error 13 -
type mismatch. If I remove:
strSQL = "INSERT INTO tblHolidays (Country, Holiday,
HolidayDt)" & _
"VALUES (" & Chr$(34) & strCurrCountry & Chr$(34) & ","
& _
Chr$(34) & varHolidayInformation(0) & Chr$(34) & ", " & _
varHolidayInformation(1) & ")"

the table is populated but the dates are misinterpreted by access:

Country Holiday HolidayDt
United Kingdom Battle of the Boyne (N. Ireland) 19/01/1900 10:31:50
United Kingdom Battle of the Boyne (N. Ireland) 22/01/1900 20:34:17
United Kingdom Battle of the Boyne (N. Ireland) 22/01/1900 20:51:26
United Kingdom Battle of the Boyne (N. Ireland) 22/01/1900 21:08:34
United Kingdom Battle of the Boyne (N. Ireland) 22/01/1900 21:25:43
--
Thanks in advance for any help.
Sue


hughess7 said:
Thanks very much Douglas, trying to get this working but a few probs. Can you
check the strsql statement please as the compiler wanted an extra ) at the
end so I had to modify to the following to get it to accept the code:

strSQL = "INSERT INTO tblHoliday (Country, Holiday,
HolidayDt)" & _
"VALUES (" & Chr$(34) & strCurrCountry & Chr$(34) & ","
& _
Chr$(34) & varHolidayInformation(0) & Chr$(34) & ", " & _
CDate(varHolidayInformation(1) & ")")

For some reason the country line does not read in correctly, access
interprets it as "ÿþ[United Kingdom] 55". Therefore the first If statements
are skipped and it reads this into the varholidayinformation. I then get an
run time error 9 on the strsql, subscript out of range.

I will try and replace the brackets [] with different characters and see if
this works...

Thanks
Sue



Douglas J. Steele said:
It shouldn't be all that difficult to write code to read it.

Use the Line Input statement to read the text one line at a time.

Throw away blank lines.

If a line starts with [ and has ] somewhere later in it, determine what's in
between the brackets, and that's your current country. If you're interested
in holidays for that country, use the Split function on each of the
following rows to divide into the holiday name and date. You now know the
locale, holiday and date: you can insert into your table.

Continue untill the next country, or the end of the file.

Something like the following untested air-code:

Dim intFile As Integer
Dim intPos As Integer
Dim strCurrCountry As String
Dim strCurrLine As String
Dim strSQL As String
Dim varHolidayInformation As Variant

intFile = FreeFile()
Open "full path to file" For Input As #intFile

Do While Not Eof(intFile)
Line Input #intFile, strCurrLine
If Len(strCurrLine) > 0 Then
If Left$(strCurrLine, 1) = "["
intPos = InStr(2, strCurrLine, "]")
If intPos > 0 Then
strCurrCountry = Mid$(strCurrLine, 2, intPos - 2)
End If
Else
varHolidayInformation = Split(strCurrLine, ",")
If IsNull(varHolidayInformation) = False Then
strSQL = "INSERT INTO tblHoliday (Country, Holiday,
HolidayDt) " & _
"VALUES (" & Chr$(34) & strCurrCountry & Chr$(34) & ",
" & _
Chr$(34) & varHolidayInformation(0) & Chr$(34) & ", " &
_
CDate(varHolidayInformation(1) & ")"
CurrentDb.Execute strSQL, dbFailOnError
End If
End If
End If
Loop

Close #intFile

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Hi Dan,

Thanks for your reply, I know it is just a text file and what the
structure
looks like - I just don't know how to read it into Access and was asking
for
some assistance with that. I know the code for importing a text file but
not
sure how to get all the right text into the relevant fields. I would like
to
store the fields Country, HolidayTxt, Date based on the following
structure.
How do I tell Access the Country is the bit in the brackers etc etc... ? I
don't want all the countries (eg US not required) but I can strip these
out
manually first if necessary. I also wandered if anyone else had already
utilised this file in a similar manner and had some code for it?

[United Kingdom] 55
Battle of the Boyne (N. Ireland),2003/7/14
Boxing Day,2003/12/26
Christmas Day,2003/12/25

Thanks
Sue


:

Hi,
It's just a text file so you can open it with Notepad and have a look at
the
structure.
You would have to then decide how you want to store it in Access. I mean,
you probably wouldn't
want to just store the info all in one table as it would not be
normalized.

--

HTH
Dan Artuso, Access MVP



Hi, I need a holiday table in my database so I can use it to exclude
any
public holidays when planning itineries. Due to the fact that we
operate
throughout Europe the outlook.hol file which comes with Outlook would
be
ideal as a basis. Has anyone used this as an import to Access? If so, I
would
appreciate any help!

I did use it to add them all to an Exchange Public Folder and tried
importing this (File, Import from Access) but the table it produced
excluded
the actual date of the holiday (appointment) which I found odd? It only
had
dates for creation, last modified etc.

My coding skills are very basic so if anyone offer some advice it would
be
most appreciated.

Thanks in advance for any help.
Sue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top