By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,988 Members | 1,367 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,988 IT Pros & Developers. It's quick & easy.

extracting specific words to different fields automatically

P: n/a
hi guys,
i was wondering if it is possible to extract selected words in a
field to be put in different fields automatically. Do i have to write
the code in vb?

This is what im trying to do. Write now, i have emails that i
receive in outlook and i want to transfer them into a database. I
realized that i could export this. however, the BODY section of the
email is exported as one field. As the email i receive is a template
and it is always in a specific form. Is there anyway i can extract the
data and place them into different fields?

Thanks.
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 5 Sep 2004 22:13:00 -0700, br********@gmail.com (Branden) wrote:

Yes, you'll have to write some VBA code to parse the Body text.
Assuming this is your body text:

FirstName: Tom<CRLF>
LastName: van Stiphout<CRLF>
<etc>

Note that <CRLF> stands for a carriage return / linefeed pair of
characters, the typical (invisible) separator characters between two
lines of text.

Now write code like this (note: air code ahead):

Sub WriteBodyToDb(byval strBody as string)
dim strFirstName as string
dim strLastName as string
strFirstName=GetFieldValue(strBody, "FirstName: ")
strLastName=GetFieldValue(strBody, "LastName: ")
'etc.

'TODO: Write the values to the Db. Perhaps using a recordset, or an
Append query.
end sub

private function GetFieldValue(byval strBody as string, byval
strFieldHeader as string)
dim intStartOfField as integer
dim strField as string
intStartOfField=GetStartOfFieldValue(strBody, strFieldHeader)
if intStartOfField>0 then
strField=Mid$(strBody, intStartOfField, Instr(intStartOfField,
strBody, vbCrLf))
GetFieldValue=strField
end function

private function GetStartOfFieldValue(byval strBody as string, byval
strFieldHeader as string)
dim intPos as integer
intPos=instr(strBody, strFieldHeader)
if intPos>0 then intPos=intPos+len(strFieldHeader)
GetStartOfFieldValue=intPos
end function

Happy coding!
-Tom.

hi guys,
i was wondering if it is possible to extract selected words in a
field to be put in different fields automatically. Do i have to write
the code in vb?

This is what im trying to do. Write now, i have emails that i
receive in outlook and i want to transfer them into a database. I
realized that i could export this. however, the BODY section of the
email is exported as one field. As the email i receive is a template
and it is always in a specific form. Is there anyway i can extract the
data and place them into different fields?

Thanks.


Nov 13 '05 #2

P: n/a
Thanks a bunch. I'll give it a try.

branden

Tom van Stiphout <no*************@cox.net> wrote in message news:<ln********************************@4ax.com>. ..
On 5 Sep 2004 22:13:00 -0700, br********@gmail.com (Branden) wrote:

Yes, you'll have to write some VBA code to parse the Body text.
Assuming this is your body text:

FirstName: Tom<CRLF>
LastName: van Stiphout<CRLF>
<etc>

Note that <CRLF> stands for a carriage return / linefeed pair of
characters, the typical (invisible) separator characters between two
lines of text.

Now write code like this (note: air code ahead):

Sub WriteBodyToDb(byval strBody as string)
dim strFirstName as string
dim strLastName as string
strFirstName=GetFieldValue(strBody, "FirstName: ")
strLastName=GetFieldValue(strBody, "LastName: ")
'etc.

'TODO: Write the values to the Db. Perhaps using a recordset, or an
Append query.
end sub

private function GetFieldValue(byval strBody as string, byval
strFieldHeader as string)
dim intStartOfField as integer
dim strField as string
intStartOfField=GetStartOfFieldValue(strBody, strFieldHeader)
if intStartOfField>0 then
strField=Mid$(strBody, intStartOfField, Instr(intStartOfField,
strBody, vbCrLf))
GetFieldValue=strField
end function

private function GetStartOfFieldValue(byval strBody as string, byval
strFieldHeader as string)
dim intPos as integer
intPos=instr(strBody, strFieldHeader)
if intPos>0 then intPos=intPos+len(strFieldHeader)
GetStartOfFieldValue=intPos
end function

Happy coding!
-Tom.

hi guys,
i was wondering if it is possible to extract selected words in a
field to be put in different fields automatically. Do i have to write
the code in vb?

This is what im trying to do. Write now, i have emails that i
receive in outlook and i want to transfer them into a database. I
realized that i could export this. however, the BODY section of the
email is exported as one field. As the email i receive is a template
and it is always in a specific form. Is there anyway i can extract the
data and place them into different fields?

Thanks.

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.