Hello.
I have, in my current project a Form with a RichTextBox control placed on it. A user is able to open a new document and type into it, or open a text file and have the text placed into another instance of this RichTextBox control.
Once this happens, the user may select a menu or click on a button which invokes a function named CheckSpelling() which is coded in the General declaration of the Form which contains this control.
Here are the problems:
In the frmMDIMain's Option Explicit section, the following is declared:
Private actCtl As Control
The spell checker part of the program works. It starts Word and takes the text within the control and copies it into Word and then invokes the spell checker of Word(97).
When it exits, the program crashes. It crashes two different ways.
1st, within the mnuEditPaste_Click event it crashes with this -
"object doesn't support property or method"
OR 2nd, it crashes with this -
"Can't open Clipboard"
actCtl.SelText Clipboard.GetText
I understand the first error, because what is being attempted here is to determine what the active control here is and SelText is only a method of a TextBox, ComboBox, ImageBox or a RichTextBox.
I changed this variable declaration to -
Private actCtl As RichTextBox
This worked. For the very first time, I could type something into a new document, invoke the CheckSpelling() function, make corrections and have those corrections pasted back into the original document.
Then I tried it again; and again.
Then it crashed with other, less occuring run-time error -
"Can't open Clipboard."
Any thoughs on this actCtl variable and is there some sort of code management needed to be applied here for the Clipboard? My version of MSDN help showed that there were some VB constants for determining what type of data was to be sent (copied) to the Clipboard, vbCFText, but I couldn't find any more info on it. The Object Browser didn't include any info on these constants.
With actCtl As RichTextBox,
what is the problem with...
actCtl.SelText Clipboard.GetText
???
Jim