-
Bulk rename based on contents in document
Hi there,
I have a set of 50 documents in a folder on my desktop with the following naming scheme:
50000.docx
50001.docx
50002.docx
.
.
.
50050.docx
I am trying to do a bulk rename of these documents based on contents stored within specific textboxes.
I can do this one at a time with the below code; however, it is quite a laborious process.
Sub FileSaveAs()
Dim StrNm As String
With ActiveDocument
StrNm = .Shapes(4).TextFrame.TextRange.Text & " " & .Shapes(36).TextFrame.TextRange.Text
With Dialogs(wdDialogFileSaveAs)
.Name = StrNm
.Show
End With
End With
End Sub
There are two complications here:
1) Not all of these word documents are actually word documents, and so the code must be able to move onto the next document if the Documents.Open function fails, and
2) Not all of the documents have textboxes from which there is data to extract
In both instances, the name of the file can remain the same.
I'm hoping 50000.docx can be renamed to the contents of 'Shape(4)' & 'Shape(36)'.docx in each document that is 1) able to be opened, and 2) where these shapes exist
Any guidance would be greatly appreciated.
Cheers,
enjam
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules