Solved

vb problem reading text from Word tables

Posted on 2012-12-26
3
228 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
My experience with Windows 10 over a one year period and suggestions for smooth operation
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now