User Defined Function in Excel that returns a String of the first selection of Spell Check

BillyBumkin

New Member
Joined
Sep 30, 2022
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hello!
I have been trying to create a UDF for a that would be passed a string, have that string run through Excel's spell check, and (if misspelled) return the first spelling value suggestion. If spelled correctly, '' would be returned.
What I have a list of thousands of misspelled cells and wanted to create this function as a first pass in correcting the spelling.

The corrected return value would then be used in a VLOOKUP to validate that the suggested string is correct.

I have seen some Word SUBs that attempt to do something similar, but they don't seem to work for me in Excel.

Many thanks!
BB
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
VBA can invoke spell check but there is no API for spell check that allows you to query its status, misspelled words, or suggestions for corrections. If you give it a string it just returns TRUE or FALSE. If you apply it to a worksheet it just invokes the user interface for spell check.

It might be possible to write your own custom code to access the spelling dictionary and locate misspelled words but giving suggestions for corrections is a bit more complicated.
 
Upvote 0
WORD VBA seems to have statements that can query the Spell Checker, but I don't see any equivalent in EXCEL:

WORD example:
Dim strWord As String: strWord =
Dim sssGetSpellingSuggestions As SpellingSuggestions
Set sssGetSpellingSuggestions = GetSpellingSuggestions(Word:=strWord)

S2 = wd.GetSpellingSuggestions(r)(1)

Is there a way to use these WORD VBA functions within EXCEL VBA?
BB
 
Upvote 0
You could create an instance of Word in Excel VBA and then call that.
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top