• Convert filename to date text in document – Fields plus VBA?

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Convert filename to date text in document – Fields plus VBA?

    Author
    Topic
    #488517

    For a very long time I’ve been building a weekly task grid using a complex set of SEQ and REF fields to create date headings for the table. Unfortunately I have to set the starting day and month manually for each document. Yet each document has the starting date embedded in its filename.

    So, what I would like to do is extract the starting date from the filename, turn it into a date that I can increment, and display the sequence of seven dates. The extraction needs to be done whenever the filename changes, since I usually just Save As the previous week’s file to begin.

    I’ve discovered all sorts of fun problems with this:
    – Word has no text manipulation fields
    – Word has no date manipulation fields
    – Word VBA can only be saved in docm and dotm files
    – Word VBA doesn’t seem to have an OnSave event
    – etc

    Before I spend any more time on this, I’m wondering what my best option is to proceed.

    1. Save my time and keep manually editing the SEQ fields.
    2. Use a FILLIN field to update the SEQ fields from a dialog box. (Will I have to reenter every time I open the document?)
    3. Get Word to treat part of the filename (eg: “Info20130105.docx”) as a number. How?
    4. Create a macro in the template to pop up a dialog whenever I create a new doc or Save As to prompt me for the starting date to set the initial SEQ fields or a BOOKMARK. How do I access these events? Is SEQ or BOOKMARK better?
    5. Same as 4, but use the filename, not a dialog.
    6. Same as 4 or 5 but skip fields altogether and let the macro do all the work.

    Any suggestions?

    Thanks heaps. This has been bugging me for years.

    Viewing 0 reply threads
    Author
    Replies
    Viewing 0 reply threads
    Reply To: Convert filename to date text in document – Fields plus VBA?

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: