Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 11-20-2014, 10:15 PM
gmayor's Avatar
gmayor gmayor is offline How to rename the word doc with the name mentioned in the body of the document Windows 7 64bit How to rename the word doc with the name mentioned in the body of the document Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,144
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to rename multiple Word file with same suffix ozil61 Word VBA 2 05-06-2014 07:36 AM
How to rename the word doc with the name mentioned in the body of the document How to specify Document Title from the body of my Document SymphonyTomorrow Word 9 08-05-2013 05:31 PM
How to rename the word doc with the name mentioned in the body of the document Rename Document & Save d4okeefe Word VBA 4 05-23-2013 09:35 AM
How to rename the word doc with the name mentioned in the body of the document How to import Word Style Headings and body text into Excel antztaylor Excel 5 11-08-2012 09:54 PM
How to rename the word doc with the name mentioned in the body of the document Advancing Paragraph Numbers in Merge Document Body Wyskers Mail Merge 1 11-30-2011 04:46 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:14 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft