设置WORD表格中数字的千分位格式守柔的经典代码里有一个是批量设置千分位格式的,如下Sub批量设置千分位格式()DimmyRangeAsRangeDimmyValueAsDoubleApplication.ScreenUpdating=FalseDo'进入一个循环'定义myRange为活动文档的主文字部分SetmyRange=ActiveDocument.ContentWithmyRange.Find.ClearFormatting.Text=[0-9]{4,}[!年].MatchWildcards=TrueIf.Execute=FalseThenExitDo'如果没找到则退出循环myValue=Val(myRange.Text)'取得数字myRange.SetRangemyRange.Start,myRange.End-1'重新定义myRange对象myRange.Text=VBA.Format$(myValue,#,###)'写入千分位格式EndWithLoopApplication.ScreenUpdating=TrueEndSub但对含有表格的数字无效,依据此代码,绕了个弯,写了个可以替换表格中数字的千分位格式的代码,请指正。SubSetThousands()DimtheTBAsTableDimtheCellAsCellDimsTextAsStringDimRegExAsObjectDimRegMatchCollectionAsObjectSetRegEx=CreateObject(vbscript.regexp)WithRegEx.Global=True.IgnoreCase=True.Pattern=[0-9]{4,}'[!年]EndWithSettheTB=ActiveDocument.Tables(1)ForEachtheCellIntheTB.Range.CellssText=VBA.Replace(theCell.Range.Text,Chr(13),)sText=VBA.Replace(sText,Chr(7),)SetRegMatchCollection=RegEx.Execute(sText)IfRegMatchCollection.Count0ThentheCell.Range.SetRangetheCell.Range.Start,theCell.Range.End-1theCell.Range.Text=VBA.Format$(sText,#,###)EndIfNextEndSub