+ Reply to Thread
Results 1 to 2 of 2

Word VBA Field FileName - remove extension

  1. #1
    Registered User
    Join Date
    03-08-2016
    Location
    Newport
    MS-Off Ver
    2010
    Posts
    17

    Angry Word VBA Field FileName - remove extension

    I have a macro that replaced the header and footer of all documents in a directory with the one in the document that I run the macro from. I have a field in the footer that shows the document name - this updates with every document however shows the .doc extension. Is there anyway to remove this extension from every field with FileName in please?

    Thanks.

    Code updating the footer and the field:

    For Each HdFt In .Sections.First.Footers
    If HdFt.Exists Then
    If wdDocSrc.Sections.First.Footers(HdFt.Index).Exists Then
    HdFt.Range.FormattedText = wdDocSrc.Sections.First.Footers(HdFt.Index).Range.FormattedText
    End If
    End If
    Next
    'NEW
    For Each aStory In wdDocTgt.StoryRanges
    For Each aField In aStory.Fields
    aField.Update
    Next aField
    Next aStory
    'HERE
    .Close SaveChanges:=True
    End With

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Word VBA Field FileName - remove extension

    Although you could edit the field display to delete the extensions, Word will re-insert them next time anything causes the field to update. There is also no field switch to suppress the extension display. If you're desperate to hide the extensions, you could position a borderless rectangular shape over that part of the field, but that's a lot of extra work just to hide the extension.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

+ 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. Macro in Windows 7 needs extension for filename
    By Arito in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-29-2016, 08:47 PM
  2. Creating a list of ascending numbers with a filename extension ?
    By just_a_man in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-24-2014, 03:21 AM
  3. [SOLVED] Loop through files and use the filename without extension
    By desolatori in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-06-2014, 06:05 AM
  4. [SOLVED] Getting filename without extension and seperating the value based on a character
    By szpt9m in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-29-2014, 02:17 AM
  5. Windows XP : Delete extension of filename
    By london7871 in forum Microsoft Windows Help
    Replies: 3
    Last Post: 12-22-2011, 09:38 AM
  6. Excel 2007 : remove extension in header filename
    By Rob44 in forum Excel General
    Replies: 0
    Last Post: 10-24-2011, 07:07 PM
  7. Getting only the filename with no extension
    By Barry Clark in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-26-2006, 02:55 PM

Tags for this Thread

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