Results 1 to 9 of 9
  1. #1
    Lounger
    Join Date
    May 2001
    Location
    Arlington Heights IL
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Generating a file name without its extension (Word 2000)

    I.ve been trying to include the last node of the file name in the document itself. The tricky part is that the file's extension -- the .doc -- must not appear. The "filename" command includes the extension, so, unless there's a way to modify it, I can't use it. Any ideas?

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New York
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Generating a file name without its extension (Word 2000)

    If you can use a macro to do the insertion, this will work:

    <pre>Sub TestIt()
    MsgBox FileNameOnly(ActiveDocument.FullName)
    End Sub

    Function FileNameOnly(FullName As String)
    Dim fs As Object
    Set fs = CreateObject("Scripting.FileSystemObject")
    FileNameOnly = fs.GetBaseName(FullName)
    End Function

    </pre>


    If you're using a field {filename} I don't think there's a way to modify it.

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Generating a file name without its extension (Word 2000)

    Another macro-based solution that might be more invisible to your users and potentially easier to maintain would be to create a custom document property called BaseName. In your template, this would be set to something arbitrary like TBD. As part of the SaveAs process (intercept the SaveAs command using, for example, Sub FileSaveAs), you could set the property to the correct string. Where you normally would use the FileName field, you then could use:

    { DOCPROPERTY "BaseName" * MERGEFORMAT }

    Of course, this assumes a lot of things about your environment...

  4. #4
    Lounger
    Join Date
    May 2001
    Location
    Arlington Heights IL
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Generating a file name without its extension (Word 2000)

    Thanks for the help. But my folks are uneasy with macros. What I've managed to do is
    Insert a FileName field where I need it to print ,
    Save the Word file = the .doc
    Close the file
    In Explorer, rename the file, removing the extension
    Open the file via Explorer
    Update the field = .doc is gone.

    Macabre, I know
    Current question is -- what can happen to that file without it's extension? It will be kept in a versioning software environment, where most folks will be able to read it via Acrobat PDF while select others will be able to access it for editing purposes..

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Generating a file name without its extension (Word 2000)

    Windows 9x and 2000 don't recognize a Word file without the extension. How did you open it? Other programs might misbehave as well. On this issue, my recommendation is not to buck the system.

  6. #6
    Lounger
    Join Date
    May 2001
    Location
    Arlington Heights IL
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Generating a file name without its extension (Word 2000)

    My test files open, directly into Word, from Explorer. There it has that generic "page with a flying window" icon. Once saved in Word, it retains its extensionless state, and opens from the list at the bottom of the File menu. Documentum, the versioning software, will also open it, but it's given its own ''name" it our installation of that system. Not very pretty, I admit.

    But I agree that "bucking the system" is not the better part of valor.

    Gave me an idea. I'll see if I can get something else to open it.

    Thanks for your support.

  7. #7
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Generating a file name without its extension (Word 2000)

    Here's another idea, not necessarily a better, or even good idea...

    Change the Windows settings for viewing files to hide the filename extensions for known file types. If you do this, the FILENAME field will give you the name without the extension.

    I think this is a very bad idea but it may be your only option.

    Another idea would be a procedure that is in your AutoNew, AutoOpen, and FileSave macros. It would create a document property 'ShortName' based on the file name. You would then use a { DOCPROPERTY ShortName } field. You've mentioned a problem with using macros so this may not be an option and even if it is, it will be some work.

    Any chance of getting your powers that be to simply accept that Microsoft can't figure out how to leave this particular DOS legacy behind?
    Charles Kyle Kenyon
    Madison, Wisconsin

  8. #8
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Generating a file name without its extension (Word 2000)

    It seems time that the powers that be at your organization learn about macros.

  9. #9
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Re: Generating a file name without its extension (Word 2000)

    Hi,

    I have had the same problem. I have overcome it by incorporating the following macro to insert the file name minus the extension and the dot (.):

    Me.txtDocName = Left(ActiveDocument.FullName, Len(ActiveDocument.FullName) - 4)

    Me.txtDocName is a textbox in a User Form and then this is inserted into the document using a bookmark.

    This must of course be coded in a template.

    Hope it can be of some help.

    Regards
    Bj

Posting Permissions

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