Results 1 to 8 of 8
  1. #1
    rkl303 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2014
    Location
    Denver
    Posts
    6

    Underlining Portion of Contents of a Text box to RTF or Horizontal Expansion

    Windows Version: 7 Enterprise 32-bit


    Office Version: 2010 32-bit

    Hello All,

    I am trying to generate a report to export to the rtf format such that the rtf looks exactly like the highlighted portion of the report in the picture below.



    The code to generate the highlighted textbox looks like this
    Code:
    ="<u>" & [project Name] & "</u> (" & [Funding ID Classification] & ":" & [9 Digit Funding ID] & "   PeopleSoft Approved Amount: " & IIf(IsNull([Approved Amount]),"",IIf(Abs([Approved Amount])>1000000,FormatCurrency([Approved Amount]/1000000,1) & "MM",IIf(Abs([Approved Amount])>1000,FormatCurrency([Approved Amount]/1000,1) & "K",FormatCurrency([Approved Amount],0)))) & ")"
    The problem I am encountering is that word/rtf file is not picking up the html code that underlines a portion of the text box
    Code:
    < u > < / u >
    And so I get this



    The only alternative I can think of to make this work correctly like in the first picture is to create two textboxes one which contains the underlined "Project Name" and the other that contains the rest of the code as stated above.



    The problem is it cuts off the projects name off as shown below.



    I have tried using the "Can Grow" feature but it only allows the project name to extend down instead of pushing the other textbox to the right



    I've tried looking for the vertical/horizontal anchoring but that is only allowed in form view. I also considered a vba script to go into rtf file and underline the components that belong to an array of the project names but if any of the projects names are mentioned in the description or status it will get underlined.

    Thank You for your help.

    Richard

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862

  3. #3
    rkl303 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2014
    Location
    Denver
    Posts
    6
    I am not sure I am following. That seems to tell me to use the <spanclass="uline"> </span> or <u> </u> which doesn't get exported out to RTF it seems.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Here is a sample.
    Attached Files Attached Files

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I did not have a lot of time yesterday to study your issue. The example in post #4 will use VBA and HTML to populate an unbound textbox (of text type RTF). At the time, I was not taking into consideration anything other than displaying RTF in a Textbox Control.

    Sometimes, when you print a report in Access, the printed result does not look the same as in print preview. The report may render two different results. A result that displays on your monitor may contain graphics, such as lines. While the other rendering does not display the same lines.

    If you are able to get the results you need using a textbox and the intrinsic underline font, you could use two controls and change the alignment so the two meet in the center. Left hand control; align right. Right hand control; align left.

    A more professional rendering would be to use the formatting events within the report's VBA module. You could incorporate the technique I provided in the example, provided the fonts are rendering in the printed version of the report.

  6. #6
    rkl303 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2014
    Location
    Denver
    Posts
    6
    Thank you for your help ItsMe but when i was referring to a RTF I was actually trying to refer to an exported version to microsoft word. If you export the report to MS Word it drops the underlining or red text in your example.

    Quote Originally Posted by ItsMe View Post
    If you are able to get the results you need using a textbox and the intrinsic underline font, you could use two controls and change the alignment so the two meet in the center. Left hand control; align right. Right hand control; align left.
    The problem is the end user is very insistent on a left aligned row and so I can't get away with that unfortunately.

  7. #7
    rkl303 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2014
    Location
    Denver
    Posts
    6
    Figured it out. I really didn't care how the report looked just how the extracted word file (RTF format) looked. So I extracted the file adding "xxxxx " and " yyyyy" to the words I wanted underlined in the report and executed the code below.

    Code:
    Function Open_Word_and_Format()
    
    
        Dim wrdApp As Word.Application
        Dim wrdDoc As Word.Document
        'Open Word
        Set wrdApp = CreateObject("Word.Application")
        wrdApp.Visible = True
    
    
        'Open the file
        Set wrdDoc = wrdApp.Documents.Open(fMain & fExport)
        
        With wrdDoc.Content.Find
            '.ClearFormatting
            .Replacement.ClearFormatting
            .Replacement.Font.Underline = wdUnderlineSingle
            .Text = "(xxxxx) (*) (yyyyy)"
            .Replacement.Text = ""
            .MatchWildcards = True
            .Execute Replace:=wdReplaceAll
        End With
        
        With wrdDoc.Content.Find
            '.ClearFormatting
            .Replacement.ClearFormatting
            .Text = "xxxxx "
            .Replacement.Text = ""
            .Execute Replace:=wdReplaceAll
        End With
        
        With wrdDoc.Content.Find
            '.ClearFormatting
            .Replacement.ClearFormatting
            .Text = " yyyyy"
            .Replacement.Text = ""
            .Execute Replace:=wdReplaceAll
        End With
        'Call Format_Word
        
        Set wrdDoc = Nothing
        Set wrdApp = Nothing
        
    End Function

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Cool, when I read the other response I was thinking automation with word. Glad you got it sorted.

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

Similar Threads

  1. Replies: 7
    Last Post: 06-06-2013, 10:32 AM
  2. Bold portion of text in memo field.
    By kenton.l.sparks@gmail.com in forum Access
    Replies: 1
    Last Post: 05-01-2012, 03:32 PM
  3. Replies: 5
    Last Post: 04-18-2012, 12:04 PM
  4. How to format contents of text box?
    By Buakaw in forum Forms
    Replies: 8
    Last Post: 03-10-2011, 06:24 AM
  5. Horizontal text alignment
    By jamil_kwi in forum Reports
    Replies: 2
    Last Post: 06-02-2010, 11:50 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