Results 1 to 12 of 12
  1. #1
    Join Date
    Apr 2008
    Posts
    189

    Question Unanswered: Export Memo field to an RTF file

    Hello,
    As usual: I have an issue.

    I have an Access 2003 database with a Memo field and I want to export the text on that field to a Microsoft Word file.

    The only way I found to export the file to a Word is via RTF.

    The problem is that the Form that I use to see the content of the Table (see attachment) has a width and the exported RTF (or TXT file) has the same width on the lines and those lines are "braked" via an "Enter character".

    So, when I try to change the Word file width I have the problem that the lines are not well formed because of the "Enter character".

    To see the problem, see attached MDB, RTF and also TXT file.

    The question will be: How can I export the text inside the Memo field to a Word without having the problem of the Form TextBox width?
    Attached Files Attached Files

  2. #2
    Join Date
    Apr 2008
    Posts
    189
    No ideas?
    Any ideas?

    How to start a solution?

    Thanks!!

  3. #3
    Join Date
    May 2005
    Posts
    1,191
    I recall having a similar problem a few years back; I can't remember exactly how I solved it, but I did manage to rummage up this site by Allen Browne which should at least get you on the right track hopefully. Cheers.
    Me.Geek = True

  4. #4
    Join Date
    Apr 2008
    Posts
    189
    Quote Originally Posted by nckdryr
    I recall having a similar problem a few years back; I can't remember exactly how I solved it, but I did manage to rummage up this site by Allen Browne which should at least get you on the right track hopefully. Cheers.
    Hey, thanks!


    ... but I still don't find the solution

  5. #5
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Generate the RTF / Text file from the memo field rather than using the form control?

    Is the text in the form split up by enter characters given by the user or are these enter characters automatically being generated?

    Hard to work this out since the attachment has absolultely no forms or code, so I can only assume you are doing this with Tools - Office Links - Publish with Word?

    I would be writing an RTF/TXT file with VBA rather than rely on things like OfficeLinks.
    Last edited by StarTrekker; 05-21-09 at 21:31.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  6. #6
    Join Date
    Apr 2008
    Posts
    189

    Smile

    Quote Originally Posted by StarTrekker
    Generate the RTF / Text file from the memo field rather than using the form control?
    Could be a solution, do you have some code to do that?

    Is the text in the form split up by enter characters given by the user or are these enter characters automatically being generated?
    The "enter characters" are added on the export.

    Hard to work this out since the attachment has absolultely no forms or code, so I can only assume you are doing this with Tools - Office Links - Publish with Word?
    Yup, I'm doing that. I'm using the "Tools --> Office Links --> Publish to Word".

    I would be writing an RTF/TXT file with VBA rather than rely on things like OfficeLinks.
    Again: do you have some code?

    And, as usual: thanks!

  7. #7
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I know there's code in the code bank for excel in vba but I'm not sure about Word. You "may" find something useful in the code bank to do what you want. Otherwise you can also google "Creating word documents via vba" or something to that affect and possibly find a few examples.

    You may want to first try doing a search on this website (using the search option) as I believe I saw code like this posted in one of the past threads.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  8. #8
    Join Date
    Apr 2008
    Posts
    189
    Thanks.

    Just for the forum growth, I leave a link: Microsoft: Access Modules (VBA Coding) - Creating Word Document ++ - How?

  9. #9
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Awesome.... does this mean you have resolved your problem?
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  10. #10
    Join Date
    Apr 2008
    Posts
    189
    Quote Originally Posted by StarTrekker
    Awesome.... does this mean you have resolved your problem?
    Well, to be honest: I have not start coding... but I think the solution goes in that way.

    :P

  11. #11
    Join Date
    Apr 2008
    Posts
    189

    Smile

    So, this is the final code:

    It's necesary the following reference: Word Object Library

    Code:
    Sub CreateWordDocument
    
        Dim wordapp As Word.Application
        Dim STRSQL As String
        Dim Conn as adodb.connection
        Dim RST as adodb.recordset
    
        Set wordapp = CreateObject("Word.application")
        WordApp.Documents.Add
    
        'Open recordset
    
        set conn = currentproject.connection
        set RST = new adodb.recordset
        STRSQL = "SELECT * FROM TBLNAME;"
    
        RSt.open strsql,conn,adOpenForwardOnly ,adLockReadOnly 
    
        'Produce Document
    
        wordapp.Visible = True
            
        With wordapp
    
            .selection.typetext RST!fieldname
    
    
        End with
        
        'tidy up
        set rst = nothing
        Set wordapp = nothing
    
    end sub
    Sources:
    Microsoft: Access Modules (VBA Coding) - Creating Word Document ++ - How?
    Creating and opening Microsoft Word document

  12. #12
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Excellent!

    Thanks for posting the solution in such detail, good job :thumb:
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •