A little too complicated for me. I think I'll just
stick with trying to figure out how to disable the
visualizations in Window Media Player control,
using a button. Is there a code for that?
I'd like to give the user an option to use it or not.
Printable View
A little too complicated for me. I think I'll just
stick with trying to figure out how to disable the
visualizations in Window Media Player control,
using a button. Is there a code for that?
I'd like to give the user an option to use it or not.
Its not hard. If you look at teh two coding examples of Early vs Late you can see the only differences are ...
Early:
Add a reference to Word (or whatever you are automating)
Late:
No reference needed
Declare variables as Object
Declare Constants yourself as no reference means they wont be declared
For the WMP question, have you tried a search yet?
Ps, dont give up so soon. ;)
Thanks for the encouragement.
Post up any more questions or issues you come across and we all would be happy to help.
Thanks for the code
Good Work :)
Moring All, first time here - exciting!
I'm trying to get this goint in Access for 2 reasons: 1. it looks awsome and I like it therfore I want to (already got the built in one working fine but you know :)) 2. Acess 2007 runtime doesn't have a spell check and I need to add one.
I've imported the code and popped it into a new module. I've already got a reference to word 11 so I'm guessing I'm in with early binding (in 2003 at the mo, work out 2007 later).
Just running debug and had to change the mouse pointer to 11 which makes me think I should be using late binding?? Anyway, whilst debuggin, it stops at App.OleRequestPendingTimeout = 999999 with a variable not defined - I'm guessing I need to either add a reference or make a change in accordance with late binding? Not sure how though, any help would be greatly appreciated.
Martyn
I have been using this code quite successfully for some time but have now hit a problem. The scenario is a VB6.0 application using Office 2010 spell check. Sometimes it works and sometimes the users get a message stating that Spell check is currently unavailable. Below is the code from my app:
Any help would be greatly appreciated.Code:Public Function SpellMe(ByVal msSpell As String) As String
On Error GoTo No_Bugs
Dim oDoc As Word.Document
Dim iWSE As Integer
Dim iWGE As Integer
Dim sReplace As String
Dim lresp As Long
If msSpell = vbNullString Then Exit Function
InitializeMe
If gDiags Then
frmDiags.AddLine moApp.Version
End If
Select Case moApp.Version
Case "9.0", "10.0", "11.0", "12.0", "14.0"
Set oDoc = moApp.Documents.Add(, , 1, True)
Case "8.0"
Set oDoc = moApp.Documents.Add
Case Else
MsgBox "Unsupported Version of Word.", vbOKOnly + vbExclamation, "VB/Office Guru™ SpellChecker™"
Exit Function
End Select
Screen.MousePointer = vbHourglass
App.OleRequestPendingTimeout = 999999
oDoc.Words.First.InsertBefore msSpell
iWSE = oDoc.SpellingErrors.count
iWGE = oDoc.GrammaticalErrors.count
'<CHECK SPELLING AND GRAMMER DIALOG BOX>
If iWSE > 0 Or iWGE > 0 Then
'<HIDE MAIN WORD WINDOW>
moApp.Visible = False
If (moApp.WindowState = wdWindowStateNormal) Or (moApp.WindowState = wdWindowStateMaximize) Then
moApp.WindowState = wdWindowStateMinimize
Else
moApp.WindowState = wdWindowStateMinimize
End If
'</HIDE MAIN WORD WINDOW>
'<PREP CHECK SPELLING OPTIONS DIALOG BOX (MODIFY TO YOUR PREFERENCES)>
moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.options.CheckGrammarWithSpelling = True
moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.options.SuggestSpellingCorrections = True
moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.options.IgnoreUppercase = True
moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.options.IgnoreInternetAndFileAddresses = True
moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.options.IgnoreMixedDigits = False
moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.options.ShowReadabilityStatistics = False
'</PREP CHECK SPELLING OPTIONS DIALOG BOX (MODIFY TO YOUR PREFERENCES)>
'<DO ACTUAL SPELL CHECKING>
moApp.Visible = True
moApp.Activate
lresp = moApp.Dialogs(wdDialogToolsSpellingAndGrammar).display
'</DO ACTUAL SPELL CHECKING>
If lresp < 0 Then
moApp.Visible = True
MsgBox "Corrections Being Updated!", vbOKOnly + vbInformation, App.ProductName
Clipboard.Clear
oDoc.Select
oDoc.Range.copy
sReplace = Clipboard.GetText(1)
'<FIX FOR POSSIBLE EXTRA LINE BREAK AT END OF TEXT>
If (InStrRev(sReplace, Chr(13) & Chr(10))) = (Len(sReplace) - 1) Then
sReplace = Mid$(sReplace, 1, Len(sReplace) - 2)
End If
'</FIX FOR POSSIBLE EXTRA LINE BREAK AT END OF TEXT>
SpellMe = sReplace
ElseIf lresp = 0 Then
MsgBox "Spelling Corrections Have Been Canceled!", vbOKOnly + vbCritical, "VB/Office Guru™ SpellChecker"
SpellMe = msSpell
End If
Else
MsgBox "No Spelling Errors Found" & vbNewLine & "Or No Suggestions Available!", vbOKOnly + vbInformation, _
"VB/Office Guru™ SpellChecker"
SpellMe = msSpell
End If
'</CHECK SPELLING AND GRAMMER DIALOG BOX>
oDoc.Close False
Set oDoc = Nothing
'<HIDE WORD IF THERE ARE NO OTHER INSTANCES>
If KillMe = True Then
moApp.Visible = False
End If
'</HIDE WORD IF THERE ARE NO OTHER INSTANCES>
Screen.MousePointer = vbNormal
Exit Function
No_Bugs:
If err.Number = "91" Then
Resume Next
ElseIf err.Number = "462" Then
MsgBox "Spell Checking Is Temporary Un-Available!" & vbNewLine & "Try Again After Program Re-Start.", _
vbOKOnly + vbInformation, "ActiveX Server Not Responding"
Screen.MousePointer = vbNormal
ElseIf err.Number = 429 Then
Set moApp = Nothing
Resume Next
Else
MsgBox err.Number & " " & err.Description, vbOKOnly + vbInformation, App.ProductName
Screen.MousePointer = vbNormal
End If
End Function
Thanks.
I dont have 2010 installed on my work computer but have you tried stepping through the code to see where the hangup lies?
It fails at Set oDoc = moApp.Documents.Add(, , 1, True) in that at the next step it says "the action cannot be performed as no document is open" or "Spell Check is currently unavailable". As far as Word 2010 goes it isn't just affecting this Spell Check code but everywhere I need to automate Word.
Thanks
Rob,
I reworked your code into a "drop in" class module that does it's own initializing and termination, negating the user doing so in their form code. I also added some extra properties and events. Your copyright suggests I should ask permission before posting it here. Would it be okay to do so?
Thanks!
- Kev
Hopefully this thread is still being followed? Maybe? :)
I discovered something in your sample that doesn't make sense, and damned if I can find the answer in MSFT's docs.
If you change the CheckGrammarWithSpelling option to false, and click Cancel on the Dialog, lResp returns -1 (versus 0 for Cancel/Close). Switching it back to True restores normal behaviour.
So, any idea why that might be?
I'm tossing around checking the spelling errors count for something > 0 as clicking Cancel does not lower the error count like Ignore does.
If memory servers me right, the calcel/close values are not self explainatory. There is also a third value -2 which means something too.
I will dig up my old files and see what somments I have from r n d.
Rob -
The MSDN says the following (http://msdn.microsoft.com/en-us/libr...g.display.aspx)
-2 = The Close button.
-1 = The OK button.
0 (zero) = The Cancel button.
> 0 (zero) = A command button: 1 is the first button, 2 is the second button, and so on.
My observation is, based on the Grammar check set to false is the return value is always -1, regardless what button is clicked. Odd behaviour to say the least (but with MSFT, this is typically the norm, especially when ti comes to automating various office classes). As I noted before, I was able to compensate for this by checking for unchecked errors after the user cancels out. Couldn't figure out why the return value is so flaky, so...
I'd still like to get your permission to post my class based on your code. I think you'd find the enhancements nod worthy. ;-)
Today i have also come up with the same problem. Everything works fine but when you try to use Word 2010, it gives the following error. However my error description is slightly different
4605 The Add method or property is not available because the document is a rich text edit control.
I've found out the reason for this problem but don't have any idea how to resolve this? The error occurs when there is an unclosed instance of Spell Checker in the Task Manager (don't know why it remains in task manager). If you close that and re-run the application, it works.
Rob, could you please let me know how to avoid this error?
I know this is an old thread but we recently starting having issues where the word that is misspelled is no longer being displayed in the 'Not in Dictionary' portion of the spell checker. I have created a new project from RobDog888 example in this thread and that is doing the same thing. Anyone else experiencing this and/or have suggestions on how to get it to display the misspelled word again? I suspect it is a MS change/update to office.
Here is an example. Thanks!
Attachment 187199
I noticed! :)