Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #15  
Old 06-23-2014, 08:45 AM
jpb103's Avatar
jpb103 jpb103 is offline Retrieving Rich Text from a RTF Text box in a User Form Windows 7 64bit Retrieving Rich Text from a RTF Text box in a User Form Office 2007
Advanced Beginner
Retrieving Rich Text from a RTF Text box in a User Form
 
Join Date: May 2014
Location: Thunder Bay, Ontario
Posts: 58
jpb103 is on a distinguished road
Default

OK, I figured it out. The solution? Don't use SetFocus at all! I have no idea why SetFocus fails so miserably at its only intended function, but there it is. Final code follows:
Code:
'///////////////////////////////////////////////////////////////////////////////////
'////////////This function inserts the form data into the table/////////////////////
'///////////////////////////////////////////////////////////////////////////////////
Private Sub OKButton_Click()
 
Dim oTbl As Word.Table
Dim oRow As Row
Dim oRng As Word.Range
Dim oCtr As InlineShape
Dim dRTF As Word.Documents
'Declare variables
Select Case True
    Case DescriptionBox = vbNullString
        'Check for empty description box
      MsgBox "You must enter a description"
    Case PriorityCombo = vbNullString
        'Check for empty priority box
        MsgBox "You must select the priority."
    Case Else
        'Input is good, add to table
        Set oTbl = ActiveDocument.Tables(1)
        Set oRow = oTbl.Rows.Add
        'Add new row for data
        DescriptionBox.SaveFile ("Temp.rtf")
        Documents.Open FileName:="\\Server\EMPNum$\G\Temp.rtf", _
        ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
        PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
        WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
        wdOpenFormatAuto, XMLTransform:=""
        Selection.WholeStory
        Selection.Copy
        oRow.Cells(1).Range.PasteAndFormat (wdPasteDefault)
        oRow.Cells(2).Range.Text = PriorityCombo.Text
        Set oCtr = oRow.Range.Cells(3).Range.InlineShapes.AddOLEControl(ClassType:="Forms.CheckBox.1")
        oCtr.OLEFormat.Object.Caption = ""
        oCtr.OLEFormat.Object.Width = 14
        'Populate columns
        Unload Me
        'Unload form
        Windows("Temp.rtf [Compatibility Mode]").Close
        DeleteFile ("Temp.rtf")
End Select
End Sub
'//////////////////END//////////////////////////////////////////////////////////////
 
'///////////////////////////////////////////////////////////////////////////////////
'////////////////////Programmed by: John P. Brunetta////////////////////////////////
'///////////////////////Position: Summer Student////////////////////////////////////
'/////////////This function unloads the user form, frmNewItem///////////////////////
'///////////////////////////////////////////////////////////////////////////////////
Private Sub CancelButton_Click()
 
Unload Me
'Unload form
End Sub
'//////////////////END//////////////////////////////////////////////////////////////
 
'///////////////////////////////////////////////////////////////////////////////////
'//////////This function initializes the contents of the Priority combobox//////////
'///////////////////////////////////////////////////////////////////////////////////
Private Sub UserForm_Initialize()
 
PriorityCombo.Clear
PriorityCombo.AddItem "SMT"
PriorityCombo.AddItem "Monthly"
PriorityCombo.AddItem "Newsletter"
DescriptionBox.SelBullet = True
End Sub
'//////////////////END//////////////////////////////////////////////////////////////
 
'///////////////////////////////////////////////////////////////////////////////////
'/////////This function checks if a file with the name passed exists////////////////
'///////////////////////////////////////////////////////////////////////////////////
Function FileExists(ByVal FileToTest As String) As Boolean
   FileExists = (Dir(FileToTest) <> "")
End Function
'//////////////////END//////////////////////////////////////////////////////////////
 
'///////////////////////////////////////////////////////////////////////////////////
'///////////////This function deletes a file if it exists///////////////////////////
'///////////////////////////////////////////////////////////////////////////////////
Sub DeleteFile(ByVal FileToDelete As String)
   If FileExists(FileToDelete) Then 'See above
      SetAttr FileToDelete, vbNormal
      Kill FileToDelete
   End If
End Sub
'//////////////////END//////////////////////////////////////////////////////////////
Special Thanks to Cosmo and NP for your help!

Last edited by jpb103; 06-23-2014 at 08:47 AM. Reason: To give thanks
Reply With Quote
 

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 09:32 PM.


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