Solved

vb problem reading text from Word tables

Posted on 2012-12-26
3
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

751 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