PDA

View Full Version : Spell check message boxes and text fields?



Movian
07-14-2015, 06:42 AM
Hey,

So I am originally from England and spell certain words slightly differently by default (Cheque instead of Check for example).

also when working on a strict deadline I sometimes miss spell something and don't notice...

I have a large Access project and I would like to run a spell check on all text in quotes (this should encompass all string values) so that I can ensure everything is looking good.

is there an easy way to do this? other than going into each form copying the code to word or notepad++ running a spell check and ignoring all commands and code sections?

thanks in advance

jonh
07-14-2015, 01:30 PM
Hard coded strings in modules?
No easy way, that I can think of.

Movian
07-15-2015, 05:08 AM
hmmmm perhaps there is room for an application to be developed here.... :)

Shouldn't be that hard to build a C# app that can use inter op to view the code then process each string and compare against dictionary, offer suggestions and replace?

Or am I simplifying too much ?

jonh
07-15-2015, 08:03 AM
AFAIK, the module has to be open before you can read it, so I don't think C# would work.

The problem is identifying strings since there are no start/end of string characters and quotes can be doubled up etc.

This is a quick test just ouputs to the immediate window so you can copy paste to something else for checking.


Private Enum mtype
Form
Module
End Enum

Private Type spos
begin As Integer
end As Integer
value As String
End Type

Private Sub Command0_Click()
moduletext mtype.Module
moduletext mtype.Form
End Sub

Private Function moduletext(ctr As mtype)
Dim db As DAO.Database
Dim m As Module
Set db = CurrentDb
For Each doc In db.Containers(IIf(ctr = Form, "forms", "modules")).Documents
Select Case True
Case ctr = mtype.Module
DoCmd.OpenModule doc.Name
Set m = Modules(doc.Name)
If m.CountOfLines Then getstrings m.Lines(1, m.CountOfLines)
DoCmd.Close acModule, doc.Name, acSaveYes
Case ctr = mtype.Form And doc.Name <> Me.Name
DoCmd.OpenForm doc.Name, acDesign
Set frm = Forms(doc.Name)
Set m = Forms(doc.Name).Module
If frm.HasModule Then If m.CountOfLines Then _
getstrings m.Lines(1, m.CountOfLines)
DoCmd.Close acForm, doc.Name, acSavePrompt
End Select
Next
End Function

Private Sub getstrings(s As String)
Dim sp As spos
Do
If sp.begin Then
sp.end = InStr(sp.begin + 1, s, """")
If sp.end = 0 Then Exit Do
sp.value = Trim(Mid(s, sp.begin + 1, sp.end - sp.begin - 1))
sp.begin = 0
If Len(sp.value) Then Debug.Print sp.value
Else
sp.begin = InStr(sp.end + 1, s, """")
If sp.begin = 0 Then Exit Do
End If
Loop
End Sub

HiTechCoach
07-20-2015, 08:56 AM
What you want to do is definitely possible to do. You can use VBA or VB or .Net.

Check out this freeware (open source) yool: V-Tools (http://hitechcoach.com/index.php?view=weblink&catid=56%3Aaccess-developer-tools-add-ins-and-vba-code&id=96%3Av-tools&option=com_weblinks&Itemid=23)

One of the tools:

Total Search
Enables to perform a full search for a string through ALL objects and their properties in the current database.
For example : if you've written "blabla" in a query description, in a property of the database, either in a personal menu, this tool will find it.

The source code is available. You could add replace.

Also check out popular tool: Find and Replace (http://www.rickworld.com/)