I am working within a quality system, and I work off of a redlined document (microsoft word). When I go to upload it into our system, I need to upload the redlined version (it says “redlines” in the filename), and then a clean copy and a pdf copy. I have recorded a macro that does everything except changing the file name. Is it possible to search for the word “redlines” in the file name, delete that word, then save it as a new file? This is what I have so far. For example, if my redlined version is called “My File Redlines.docx” I would want it to save the file as “My File.docx”. The filename can vary in length, and the location of the word “redlines” can also vary, so it can’t be based upon a fixed location.
Sub Macro1()
‘
‘ Macro1 Macro
‘
‘
ActiveDocument.Save
ActiveDocument.SaveAs2 FileName:= _
Need help how to do this part. I want to remove the word “Redlines” from the file name, _
FileFormat:=wdFormatXMLDocument, LockComments:=False, Password:=””, _
AddToRecentFiles:=True, WritePassword:=””, ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False, CompatibilityMode:=15
ActiveDocument.TrackRevisions = Not ActiveDocument.TrackRevisions
ActiveDocument.AcceptAllRevisions
ActiveDocument.Save
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
This will have the same file name as above, but saved as a PDF _
, ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False
End Sub