Solved

vb problem reading text from Word tables

Posted on 2012-12-26
3
231 Views
Last Modified: 2012-12-28
I wrote a program that reads the cells of Word (2007) tables and puts the results into a database.  Currently using Access 2007 memo fields.  Everything is fine except that the carriage returns and line breaks don't carry over into the database.  for some reason they are stripped so the resulting text is one long string.  even a blank line in the text gets stripped out when it goes into the database.
0
Comment
Question by:RBECKMN
3 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38722737
Make sure the "Text Format" property (Not to be confused with the "Format" property) of the memo field is set to "Rich Text"

Can you give us some insight into your "Program" and how it inserts the text into the field?
If setting the Text Format to Rich text does not work, then another option would be to insert the text via SQL Inserts.

Something roughly like this:
CurrentDb.Execute "INSERT INTO Yourtable (YourMemoField) VALUES ('SomeText1' & '<br>' & 'SomeText2')", dbFailOnError

...With your "Program" converting whatever character the cr/lf is in Word, ...to <br> for Rich Text (HTML)

JeffCoachman
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 38723145
Word does not records the line breaks, it records only the carriage return with one character only, Chr(13).

Access memo fields record line breaks as the more standard combination of 2 characters, Chr(13) Chr(10).

I would try something like the following:

textInBd = textInWord.Replace(Chr(10), Chr(13) & Chr(10))
0
 

Author Comment

by:RBECKMN
ID: 38728614
-- original code that was causing the problem:

TheString = theTable.cell(ThisRow, 1).Range.Text

-- the code now is:

TheString = Replace(theTable.Cell(ThisRow, 1).Range.Text, Chr(13), Chr(13) & Chr(10))

-- followed by:

therecordset(n)=theString, where n is the field number in the recordset
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question