i'm using macro to, among other things, spell check invoice i've created in excel before save it. currently, spell checks entire workbook. i'd spell check certian cells of specific sheet (because don't want spell check peoples names , addresses on invoice).
specifically, i'd spell check cells d15-d19 on sheet "invoice" , cell d38 on sheet "safety inspection"
can point me in right direction?
this vba code i'm using i'd refine:
option explicit sub saveassafety() 'saves filename value of a1 plus current date application.commandbars("tools").controls("spelling...").execute 'invokes spell check dim newfile string, fname string ' don't use "/" in date, invalid syntax fname = range("m9").value 'change date format whatever you'd like, make sure it's in quotes newfile = fname & " - " & range("d10").value & " - " & range("d9") ' change directory suit pc, including user name sheets(array("safety inspection", "invoice")).select sheets("safety inspection").activate chdir _ "c:\users\brian\google drive\buller heating , air\invoices" activeworkbook.saveas filename:=newfile activesheet.exportasfixedformat type:=xltypepdf, filename:=range("a1").value _ , quality:=xlqualitystandard, includedocproperties:=true, ignoreprintareas _ :=false, openafterpublish:=false end sub
to check spelling in specific cells try:
sub bbuller() dim boo boolean s = array("invoice!d15", "invoice!d16", "invoice!d17", "invoice!d18", "invoice!d19", "'safety inspection'!d38") each ss in s boo = checkitnew(range(ss)) if boo msgbox ss & " has no errors" else msgbox ss & " has errors" end if next ss end sub public function checkitnew(r range) boolean dim mytext string mytext = r(1).text dim oxlap object set oxlap = createobject("excel.application") checkitnew = oxlap.checkspelling(mytext) oxlap.quit set oxlap = nothing end function
Comments
Post a Comment