Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-23-2014, 06:24 AM
Cosmo Cosmo is offline Retrieving Rich Text from a RTF Text box in a User Form Windows Vista Retrieving Rich Text from a RTF Text box in a User Form Office 2007
Competent Performer
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default


Saving the text to a .rtf file looks like it works to me. You can then open the temp file (invisible if necessary), copy the range to get the formatted text, then delete the temp file.

Code:
Private Function testSaveRTF()
    Dim filePath As String
    Dim s As String
    s = "{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl {\f0\fnil\fcharset0 Tahoma;}{\f1\fnil\fcharset2 Symbol;}}{\*\generator Riched20 12.0.6606.1000;}\viewkind4\uc1\pard{\pntext\f1\'B7\tab}{\*\pn\pnlvlblt\pnf1\pnin dent0{\pntxtb\'B7}}\fi-360\li360\f0\fs17 This is an example\fs17\par }"
    filePath = ActiveDocument.Path + "\TempFile.rtf"
    Call SaveTextToFile(s, filePath)
End Function
 
Public Function SaveTextToFile(sText As String, _
                                Optional FileFullPath As String, _
                                Optional Overwrite As Boolean = False) As Boolean
    SaveTextToFile = True
On Error GoTo ErrorHandler
    Dim iFileNumber As Integer
    iFileNumber = FreeFile
    
    If Overwrite Then
       Open FileFullPath For Output As #iFileNumber
    Else
       Open FileFullPath For Append As #iFileNumber
    End If
    
    Print #iFileNumber, sText
    SaveTextToFile = True
    Close #iFileNumber
    
    Exit Function
ErrorHandler:
    SaveTextToFile = False
    Close #iFileNumber
End Function
Reply With Quote
Reply

Tags
rich text, tables, userforms



Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieving Rich Text from a RTF Text box in a User Form Rich text/Plain text Content Controls in Template michael.fisher5 Word 9 11-19-2014 06:36 AM
Retrieving Rich Text from a RTF Text box in a User Form Rich Text Content Control - Allow User Formatting keithacochrane Word 1 05-28-2012 05:06 PM
Retrieving Rich Text from a RTF Text box in a User Form How to I make text Bold in a User Form -Visual Basic gurp99 Word VBA 11 03-12-2012 04:05 PM
My plain text post got converted to rich text in a reply, how to convert it back? david.karr Outlook 0 01-05-2012 09:46 AM
Templates: automatic text generation from Rich Text content control Chickenmunga Word 0 10-01-2008 11:16 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:54 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft