How do I edit field code fieldname to exclude .doc extension?

G

Guest

In my word document, I want the fieldname in a template I created to be the
name of the document without the .doc extension. Currently when I save the
document and update field, the name is something like: PO54726.doc and I'd
like it to be PO54726
How do I do this?
 
G

Guest

Marketingcomm:

I don't know of any options or switches that wil supress the extension
included in the FILENAME field. Could you use the TITLE field instead? If
not, I'd guess you'll have to get into some VBA coding.

Here's hoping someone knows a simpler way. If not, let me know if you want
any help with the VBA.

Bear
 
G

Guest

Thank you.
TITLE doesn't work, as the template is for purchase orders. The title is
Purchase Order. The file is saved as a number and year, for example 103-07,
104-07, and so on. When the fieldname code is updated, the file name comes up
as 103-07.doc, 104-07.doc, and so on. The only other thing I can think of is
to ask all our employees to manually delete the .doc, but I want to try and
stay away from manual entries.
I haven't done any Visual Basic coding before, so could use your help, if
you think it might work.
 
G

Guest

Marketingcomm:

I'm going to make some assumptions. Please correct me if any of these sound
wrong.

You want to be able to insert a field somewhere in your template (and thus
the created documents) that displays the file name less the extension.

This isn't the PO number, it's the concatenation of the PO number and the YY
digits of the year. So in 103-07, the PO number is 103 and the file name is
103-07.doc.

Here's what I'd do. If the "103-07" field doesn't a specific name or meaning
other than part of the file name, I'd just put the value in an existing
document property, like Subject. If it does have some meaningful name, I'd
create a custom document property with that name and put the value in there.

You could start right now asking your users to enter that information in the
Subject box. You could then use the Subject field anywhere in your template
that you need. You'd promise to automate it soon.

We'd write code to create the value of that field each time the document
gets opened, but not otherwise. Depending on where you put the field, we
might want to make sure it gets updated as well, so the latest value is
displayed.

Once the assumptions are sorted out we can get on with details.

Bear
 
G

Graham Mayor

I didn't see the earlier correspondence related to this thread, but you
cannot show the filename without the extension using fields. You can with a
macro eg


Sub InsertfNameAndPath()
Dim pPathname As String
With ActiveDocument
If Not .Saved Then
.Save
End If
pPathname = Left$(.FullName, (Len(.FullName) - 4))
End With
Selection.TypeText pPathname
End Sub

Sub InsertFnameOnly()
Dim pPathname As String
With ActiveDocument
If Not .Saved Then
.Save
End If
pPathname = Left$(.Name, (Len(.Name) - 4))
End With
Selection.TypeText pPathname
End Sub

http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Guest

Graham:

That gentle "swooshing" sound you just heard is me scooping up your code for
my scrapbook. Thanks!

MaretingComm:

This is the kind of VBA I was talking about, except that I suggested storing
the results in a document property or custom document property whenever the
document opens. (That would let you put the field and thus the file name
wherever you like in the template.)

Or... You could open a userform when an document is created and ask the user
to specify the PO number, use that to create a default file name, then save
the new file with that name. Again, you'd be also putting the PO number into
a document property for use anywhere on the form.

Bear
 
G

Graham Mayor

I have been on holiday so missed the earlier part of the thread. Life is too
short to download two weeks of newsgroup messages :)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Guest

Thank you for sharing your knowledge. I'm not an expert by any means, but
you've both been most helpful.
 

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