Show filename part without extension

N

Neil

Good'ay

I am working with an organisation that names their word docs something
like...

Fred Bloggs.Q10

I can use the field FILENAME to show the filename in the document but I
want to show just the filename part (Fred Bloggs) in one place and the
extenstion (10) in another.

Eg In the document ...

Name: Fred Bloggs {extracted from the filename}

Question: 10 (extracted from the extension}

Thanks for your interest ...

Neil
 
J

Jezebel

Simple enough to write VBA to split the filename like that (eg using the
Split() function); but it might be simpler to turn the problem around: put
the name and question number into separate document properties -- which you
can display in the document using DocProperty fields -- and combine those
fields to create the filename.

Separately, it's usually unwise to use filename extensions for anything
other than identifying the type of file -- Explorer doesn't know what to do
with the file, so can't open it automatically; you can't do any automatic
searching or sorting by type; and sooner or later you come to grief with
other applications that use the same extensions (Q00 - Q04 are used by
Quicken, for a start).
 
N

Neil

Thanks for you reply (and yes, thanks for warning of misusing file
extensions)

I'm quite familiar with VBA. I know I can create a user function in
Excel and then call refer to it an excel cell. eg

function createUserName()

etc

and then use =createUserName(A3,B3) in a cell

Do you know how to do this Word?
 
J

Jezebel

Word doesn't have an equivalent of that. As in Excel, you can run macros
automatically when you open, close print, etc; but you can't associate a
part of the document directly with a macro (other than a macrobutton field,
which requires the user specifically to click the button).

As suggested previously, simplest will probably be to put the name parts
into document properties, then use DocProperty fields in the document where
you want to display the values.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top