473,320 Members | 1,887 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

return multiple lines

I have a large body of text and am trying to extract parts of that into a field in my form. i am using the following code:

Expand|Select|Wrap|Line Numbers
  1. If InStr(1, abody(j), "Extent of Work:", 1) Then
  2. strExtWork = Mid(abody(j), InStr(abody(j), "Extent of Work:") + 16)
this works well in returning one line, but sometimes the extent of work that i am trying to extract is multiple lines and i have kind of hit a wall... any ideas?

Thank you.
Jul 19 '19 #1
5 1113
NeoPa
32,556 Expert Mod 16PB
Not much really, without knowing what problem(s) you're experiencing.
Jul 19 '19 #2
I am importing the body of emails and am taking specific strings from the email and placing them in fields on a form. For text that i am capturing that is only one row it is not a problem. the problem is if the data i need to import is on multiple rows. i have tried this code:

Expand|Select|Wrap|Line Numbers
  1. Dim rowOffset As Long
  2.  
  3. If InStr(1, abody(j), "Extent of Work:", 1) Then
  4.    strExtWork = Mid(abody(j), InStr(abody(j), "Extent of Work:") + 16)
  5.  
  6.  
  7.     rowOffset = 1  ' reinit
  8.     While Left(abody(j + rowOffset), 8) <> "Remarks:" ' check if this is Remarks:
  9.         strExtWork = strExtWork & abody(j + rowOffset)
  10.         rowOffset = rowOffset + 1
  11.         Me.ExtentofWork = Trim(strExtWork)
  12.     Wend
  13.                     End If
As the end point will always be the word "Remarks:". This works for capturing multiple rows of text but if there is just a single row it does not capture that.

To summarize, I am trying to capture all text between the words "Extent of Work:" and "Remarks"

The problem is I can either capture one row, or multiple, with the codes provided, but not but situations.
Jul 22 '19 #3
ADezii
8,834 Expert 8TB
I loaded an E-Mail Item which I know has extensive Body Text into a String Variable after Trimming it and Replacing CrLfs with an Empty String. I then calculated my Positions and returned all Text between 'Extent of Work:' and 'Remarks:'. It appears to work quite well but not fully tested.
Expand|Select|Wrap|Line Numbers
  1. Dim strBody As String
  2. Dim strBody2 As String
  3. Dim intStart As Integer
  4. Dim oLook As Outlook.Application
  5. Dim oMailItems As Outlook.Items
  6. Dim msg As Outlook.MailItem
  7. Dim strFldInfo As String
  8. Dim intPos1 As Integer
  9. Dim intPos2 As Integer
  10. Const conSEARCH1 = "Extent of Work:"
  11. Const conSEARCH2 = "Remarks:"
  12.  
  13.  
  14. Set oLook = New Outlook.Application
  15. Set oMailItems = oLook.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items
  16.  
  17. For Each msg In oMailItems
  18.   If msg.Subject = "Test" Then
  19.     strBody = Replace(Trim(msg.Body), vbCrLf, "")
  20.       intPos1 = InStr(1, strBody, conSEARCH1) + Len(conSEARCH1)
  21.       intPos2 = InStr(1, strBody, "Remarks:")
  22.       strFldInfo = Mid$(strBody, intPos1, (intPos2 - intPos1) - 1)
  23.         Debug.Print strFldInfo
  24.   End If
  25. Next
  26.  
  27. Set oLook = Nothing
  28. Set msg = Nothing
  29. Set oMailItems = Nothing
Jul 23 '19 #4
twinnyfo
3,653 Expert Mod 2GB
ADezii,

Great work, as usual! Simple. Elegant. Looks functional.
Jul 24 '19 #5
ADezii
8,834 Expert 8TB
@twinnyfo
Thanks for your kind words.
Jul 24 '19 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: JStrauss | last post by:
Hello, Can anybody give me some tips on the best and/or easiest way to display multiple lines in a field. The data is collected from a "textarea" field when the form is submitted, and I want to...
2
by: Wow | last post by:
Do I have to replace all new lines with \n and document.write one line? Is there something like perl's print lines print << 'body'; body in javascripts?
4
by: tshad | last post by:
I have a textbox that I am storing as text (or as a varChar). The field has multiple lines in it (not wrapped). When I read it back into a multiline textbox, it works fine. But when I read it...
2
by: George | last post by:
Dear colleagues, I refer to your help with specific graphic problem. It is necessary to create a viewfinder in graphic application. It seems that the algorithm is simple: just draw lines in...
1
by: Loading name... | last post by:
hey asp.net 2.0 In my db (sql server 2005) I have a record which consist of multiple lines: "HEY THIS IS A TEST OF MULTIPLE LINES"
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
0
by: chitta | last post by:
Hi I have a problem when i am looping on multiple lines. the question as follows If OrderProductLineItem (DocType='OrderCreate'/'OrderChange') < OrderProductLineItem...
4
by: radha gogia | last post by:
I referred this link ,but I am unable to get the logic behind using %%*c or % as format specifier . http://stackoverflow.com/questions/14494309/reading-multiple-lines-of-input-with-scanf And...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.