+ Reply to Thread
Results 1 to 3 of 3

VBA using text from word doc to create file name. Can anyone help? Cursing isn't so far!

  1. #1
    Registered User
    Join Date
    05-08-2024
    Location
    Chicago, IL
    MS-Off Ver
    Windows 10
    Posts
    2

    VBA using text from word doc to create file name. Can anyone help? Cursing isn't so far!

    I have thousands of documents in this folder. The text looks like below in bold. I want the title to skip the text "Summary Plan Description" and "Effective" (but keep the date that follows), but then create a file name using the rest. There are no headers, footers, or file metadata I can use. The file name would read "ABC Corporation-Hiring Plans-January 1, 2022-Group Number:123456" Each document lists these items in a similar sequence and they all are structured the same just different details by vendor.

    Now, I know I can't use comma's and some other special characters. We can remove the ":" if needed. The main goal of this is to be able to search for these documents. Right now their name isn't clear. I am getting a huge data dump of these files and need to rename them. A huge bonus point would be if we could make the above file name, but then attach the existing/previous file name in there as well in parenthesis. Something like this.... "ABC Corporation-Hiring Plans-January 1, 2022-Group Number 123456 (File 12)"

    SUMMARY PLAN DESCRIPTION

    ABC Corporation
    Hiring Plans

    Effective: January 1, 2022
    Group Number: 123456


    Can anyone help? I've spent a day trying to do it myself and I know there are smarter people out there kind enough to point me in a direction. Hope everyone is having a good day!

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,843

    Re: VBA using text from word doc to create file name. Can anyone help? Cursing isn't so fa

    Now, I know I can't use comma's and some other special characters. We can remove the ":" if needed.
    The following characters are illegal in Windows file names. Commas are allowed.
    \ / : * ? " < > |
    You can't use the ":" so what do you want to do instead?

    A huge bonus point would be if we could make the above file name, but then attach the existing/previous file name in there as well in parenthesis. Something like this.... "ABC Corporation-Hiring Plans-January 1, 2022-Group Number 123456 (File 12)"
    That's certainly possible but keep in mind that very long file names can sometimes be problematic in Windows.

    These are Word documents, but you posted in Excel VBA. Excel could be used but I would use Word.

    If these documents do not contain private data, please attach at least two sample files along with telling us what you want their new names to be.

    By the way, before you would actually do the renaming I recommend making a folder with copies of the original files just as an archive. If there is a bug in the renaming code you don't want to lose the original baseline.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    05-08-2024
    Location
    Chicago, IL
    MS-Off Ver
    Windows 10
    Posts
    2

    Re: VBA using text from word doc to create file name. Can anyone help? Cursing isn't so fa

    Actually, I realized I have an excel file with the file name in column A (in black). The columns in red are the ones I want to "concatenate" with some divider such as an "-" or an "/". Any thoughts on a macro that could achieve this? Assume the files are in this location

    File example. Black is file name. Red are what we want to concatenate into new file name.
    File Name.JPG

    Archive Location (where these will be saved).
    Archive Folder.JPG


    I tried for 2 hours last night as I have a new puppy that wont let me sleep. Losing my mind. If anyone has any ideas you would make my week!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Create new Word file then Copy table and contents from Excel to that Word file
    By sbv1986 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-23-2018, 09:14 AM
  2. VBA for Insert Object >>Create from File>>Choose File. In Word Document
    By kt1993 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-08-2015, 03:43 PM
  3. Macro to find a word in a cell, create a transparent text zone over it, create a hyperlink
    By martin brandl in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-17-2015, 03:24 PM
  4. Add text to Existing Word Document if it Doesn't exist create Word Document
    By unstable81 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-10-2013, 12:15 AM
  5. Replies: 0
    Last Post: 06-15-2011, 02:22 PM
  6. How to create word file
    By Mudit in forum Excel General
    Replies: 3
    Last Post: 07-18-2006, 06:00 AM
  7. [SOLVED] Create a word file from XL
    By Sridhar Pentlavalli via OfficeKB.com in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-21-2005, 01:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1