Results 1 to 5 of 5
  1. #1
    sneuberg is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2014
    Posts
    23

    Moving Rich Text From Access Memo Field to a Word Text Box

    We need to move rich text from an Access memo field to a Word text box. So far the best I’ve been able to come up with is in the code below which is a variation of a suggestion at http://vbadud.blogspot.com/2010/09/h...ntents-to.html In this code “pprs!What is a record set field of a table memo field that is bound to a text box enabled for rich text. The rich text seems to be stored as html as so I can get word to convert it by enclosing it in html tags. This seems to work ok but I’d rather do this more directly than this kludge of writing and reading a file. Any ideas?



    Dim What As Word.Shape
    Set What = doc.Shapes.AddTextbox(msoTextOrientationHorizontal , doc.PageSetup.LeftMargin, 225, 534, 0)
    Dim sPath As String
    sPath = "G:\Temp.html"
    Open sPath For Output As 1
    Print #1, "<HTML>" & pprs!What & " </HTML>"
    Close #1
    What.TextFrame.TextRange.InsertFile (sPath)

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I don't understand, you're creating an HTML document (temp.html) but you don't want to enclose it in HTML tags? would that even work? I'd like to see code that works and what references you're using if it's not just MS office word library.

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    maybe I misunderstood, are you trying to create a word document then save it as an HTML document so it will fill in the appropriate HTML code?

  4. #4
    sneuberg is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2014
    Posts
    23
    Quote Originally Posted by rpeare View Post
    maybe I misunderstood, are you trying to create a word document then save it as an HTML document so it will fill in the appropriate HTML code?
    We are creating a word document from data in an Access database. This code works somewhat. The only additional reference we added was the Microsoft Word 15 object library.

    The following may may sound odd but it is true. If you have text box whose Text Format is Rich Text and that text box is bound to a memo field, the data that comes out of that field in a query is HTML without the HTML tags; not rich text format whatever that might be. If I type the word Bold in the text box and make it bold what come out in a query is <div><strong>Bold</strong></div>. I put the HTML tags around it before I save it to the file so that when it is inserted into the Word text box it gets interpreted as HTML and has the bold format in the final Word document. Otherwise <div><strong>Bold</strong></div> would appear in the word document which is what also happens if you feed the output of the query directly into the Word text box.

    I originally said that this seemed to be working, but it turns out that even this isn't quite right. Bullet items come out of this process with more indentation that was originally in the text box.

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Without parsing the HTML itself I don't know if you're going to solve this, trying to translate a memo field to another format (other than plain text, and sometimes even then depending on the length of the strings involved) notoriously troublesome. Can you provide a sample database so I don't have to recreate something to try and test?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Trouble with rich text format memo field
    By lawdy in forum Access
    Replies: 10
    Last Post: 03-08-2014, 08:34 PM
  2. Replies: 1
    Last Post: 11-26-2013, 06:40 PM
  3. rich text memo field
    By jedder in forum Reports
    Replies: 1
    Last Post: 05-11-2012, 02:48 PM
  4. Access 2007 Memo Field Rich Text
    By EddieN1 in forum Access
    Replies: 2
    Last Post: 08-13-2011, 08:41 AM
  5. Replies: 0
    Last Post: 03-15-2010, 01:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums