• Generating a file name without its extension (Word 2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Generating a file name without its extension (Word 2000)

    Author
    Topic
    #372686

    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?

    Viewing 2 reply threads
    Author
    Replies
    • #596440

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

      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
      
      

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

    • #596467

      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…

      • #596529

        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..

        • #597415

          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.

          • #598046

            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.

            • #598709

              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

        • #598539

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

    • #598525

      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?

    Viewing 2 reply threads
    Reply To: Generating a file name without its extension (Word 2000)

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

    Your information: