Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 5th, 2004, 04:04 PM
Authorized User
 
Join Date: Jun 2004
Location: Los Angeles, California, USA.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Rich Text Editor

Please help.
I found code to spell check rich text by using the MS Word spell
checker; however, it does not return the resulting text as rich text,
only as plain text. Can someone help me code this so it returns the
text as rich text. My prototype is at: http://www.utteraccess.com/forums/do...?Number=458369
Place this code in a module and name it "basRTF2WordSpellCheck". To use this function, place "=SpellCheck()" in the 'OnClick event for a command button on the editor form.

Code:
================================================== =====================
Option Compare Database

'Spell Check using Richtextbox to Word then back Method
Private Declare Function OpenClipboard Lib "User32" (ByVal hwnd As
Long) As Long
Private Declare Function RegisterClipboardFormat Lib "User32" Alias _
    "RegisterClipboardFormatA" (ByVal lpString As String) As Long
Private Declare Function EmptyClipboard Lib "User32" () As Long
Private Declare Function CloseClipboard Lib "User32" () As Long
Private Declare Function SetClipboardData Lib "User32" ( _
    ByVal wformat As Long, ByVal hMem As Long) As Long
Private Declare Function GetClipboardData Lib "User32" (ByVal wformat
As _
    Long) As Long
Private Declare Function GlobalAlloc Lib "kernel32" (ByVal wflags As
Long, _
    ByVal dwbytes As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (
_
    ByVal destination As Long, source As Any, ByVal length As Long)
Private Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As
Long) As Long
Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As
Long) As Long
Private Declare Function GlobalFree Lib "kernel32" ( _
    ByVal hMem As Long) As Long
Private Declare Function lstrcpy Lib "kernel32" (ByVal lstring1 As
Any, _
    ByVal lstring2 As Any) As Long

Private Const GHND = &O42
Private Const CF_TEXT = 1
'Private Const CF_RTFTEXT = &HFFFFBF01
Private Const MAXSIZE = 4096
Private Const GMEM_DDESHARE = &H2000
Private Const GMEM_MOVEABLE = &H2

'================================================= ======================
'Spell Check using Richtextbox to Word then back Method
'To use this function, place "=SpellCheck()" in the
'OnClick event for a command button on your form.
'================================================= ======================
Public Function SpellCheck()

On Error GoTo SmartFormError

Dim sRTF As String
sRTF = Forms![frmRTFEditor]![RichText]
Dim Wrtf As String
Dim lSuccess As Long
Dim lRtf As Long
Dim hGlobal As Long
Dim lpString As Long
Dim lOrgTop As Long
lSuccess = OpenClipboard(Forms![frmRTFEditor]![RichText].hwnd)
lRtf = RegisterClipboardFormat("Rich Text Format")
lSuccess = EmptyClipboard
hGlobal = GlobalAlloc(GMEM_MOVEABLE Or GMEM_DDESHARE, Len(sRTF))
lpString = GlobalLock(hGlobal)
CopyMemory lpString, ByVal sRTF, Len(sRTF)
GlobalUnlock hGlobal
SetClipboardData lRtf, hGlobal
CloseClipboard
GlobalFree hGlobal
Dim oWord As Object
Dim oDoc As Object
Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.Documents.Add
oWord.Visible = True
lOrgTop = oWord.Top
oWord.WindowState = 0
oWord.Top = -3000
oWord.Selection.Paste
oDoc.Activate
oDoc.CheckSpelling

oWord.Selection.WholeStory
oWord.Selection.Copy

Dim hClipMemory As Long
Dim lpClipMemory As Long
Dim mystring As String
Dim Retval As Long

If OpenClipboard(0&) = 0 Then
    MsgBox "cannot open Clipboard. Another app. may have it open"
    GoTo OutofHere
End If
    hClipMemory = GetClipboardData(CF_TEXT)
    'hClipMemory = GetClipboardData(CF_RTFTEXT)
    If IsNull(hClipMemory) Then
        MsgBox "Could not allocate memory"
        GoTo OutofHere
    End If
lpClipMemory = GlobalLock(hClipMemory)

If Not IsNull(lpClipMemory) Then
    mystring = Space$(MAXSIZE)
    Retval = lstrcpy(mystring, lpClipMemory)
    Retval = GlobalUnlock(hClipMemory)
    mystring = Mid(mystring, 1, InStr(1, mystring, Chr$(0), 0) - 1)
Else
    MsgBox "could not look to copy string from."
    End If

OutofHere:
    Retval = CloseClipboard()
    Forms![frmRTFEditor]![RichText] = mystring
With oWord
    .ActiveDocument.Close savechanges:=False
    .Quit
    End With

Exit_SmartFormError:
Exit Function

SmartFormError:

    If Err = 2046 Or Err = 2501 Then
        Resume Next
    ElseIf Err = 440 Then
        MsgBox "Error In Spell Check Function."
        Resume Exit_SmartFormError
    Else
        MsgBox Err.Description
        Resume Exit_SmartFormError
    End If

End Function
================================================== =====================

Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
rich editor for CMS based on ASP.NET Boogy ASP.NET 1.0 and 1.1 Professional 5 May 19th, 2005 03:45 PM
rich text editor anshul Pro PHP 4 April 6th, 2005 09:24 AM
Rich Text Editor in Java Script needed iniro Javascript 4 September 7th, 2004 04:50 AM
Rich Text Editor in Java Script needed iniro HTML Code Clinic 3 September 7th, 2004 03:54 AM



All times are GMT -4. The time now is 08:14 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.