Question Locked

Rich Text from MS Access 2007 to MS Word 2007

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi there,
I have a simple table with 3 columns in ms access 2007: EmpID (autonumber), EmpName (text, plain) and EmpBio (memo, rich text). I also have a word doc with two bookmarks for the EmpName and EmpBio. I want to copy data (while browsing the table-based form in access) to ms word doc. The Name field gets written correctly, but the biography turns into html tags.
I am using:
.Bookmarks("bmBio").Range.Text = Me.EmpBio
I know Range.FormattedText would work inside or between Word docs. But how do I make it work directly from ms Access using VBA?

6 replies

by ictperson

Thanks for your reply. I am only sending one record (the current record) which has 2 fields. How would a CSV help with the format issue?

by thumbsup2

It will strip the HTML out of the data. You can then reformat it on the Word .doc side when you read the CSV file. Copy n paste directly into Word will always bring the HTML (for formatting) along with it.

by ictperson

Thanks for your help. I could use the PlainText() function to convert to plain text (remove the tags). But I do need to preserve formatting in Word.

by sam loveridge

I've just been searching for an answer to this myself, and found another person suggesting an answer for importing HTML tables into Excel which provided a similar solution for me into Word.

The way I got around it was to use VBA to build my whole export from MS Access into HTML and save the HTML string to a file with the ".doc" extension using the FileSystemObject. I then opened the saved doc in the VBA routine into a Word.Document and manipulated it further by adding a TOC, etc.

It struck me as crazy that the VBA object model doesn't seem to support writing the MS Access "RichText" HTML data using a Range. I tried using a whole bunch of approaches (HTMLProjectItem - no longer in 2007, InsertXml with a transform, etc.) but the FSO approach was simple and straight forward - albeit feels like a workaround rather than an elegant solution.

Thanks to the following thread for the idea ....
http://www.eggheadcafe.com/tutorials/aspnet/48e4b7c2-7735-4122-83f3-3bc58854b589/client-side-script-to-exp.aspx

This discussion is closed to new replies.