View Single Post
 
Old 11-20-2014, 10:15 PM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The 'number' section of Policy number ABC3782/00088ABC contains an illegal filename character "/" So you would not be able to name a file with a string containing that character. If you were to replace it with (say) an underscore you could use

Code:
Do While .Execute(FindText:="Policy number [A-Z]{1,}[0-9]{1,}/[0-9]{1,}[A-Z]{1,}", MatchWildcards:=True)
            strText = orng.Text
            bFound = True
            vNumber = Split(strText, " ")
            ActiveDocument.SaveAs Filename:=strPath & Replace(Trim(vNumber(UBound(vNumber))), "/", "_") & ".docx"
            Exit Do
        Loop
You can search for any unique string using wildcards - see http://www.gmayor.com/replace_using_wildcards.htm
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote