{filename} can be used to display the file name.
If the file names are in the "ABC 1234.docx" format, How can I extract the 4 numeric characters starting from the 5th character in the filename, namely, "1234"?
Thanks for your help.
Extract Partial File Name
-
- 2StarLounger
- Posts: 105
- Joined: 19 Apr 2010, 10:25
- Location: Hong Kong
Extract Partial File Name
Regards,
Armstrong
Armstrong
-
- Administrator
- Posts: 78506
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Extract Partial File Name
Word doesn't offer any string manipulation functions in the interface, so I think you'll have to use VBA code. What do you want to do with the numeric characters?
Best wishes,
Hans
Hans
-
- 2StarLounger
- Posts: 105
- Joined: 19 Apr 2010, 10:25
- Location: Hong Kong
Re: Extract Partial File Name
Hi HansV,
Long time no see, my old friend/teacher. Yes, {=} formulae patently lack all string manipulation functions. My objective is to extract and print the 4 digits from the filenames.
Exhibit 1200.docx
Exhibit 1201.docx
Exhibit 1202.docx
Exhibit 1203.docx
etc.
Thanks for your fast help.
Long time no see, my old friend/teacher. Yes, {=} formulae patently lack all string manipulation functions. My objective is to extract and print the 4 digits from the filenames.
Exhibit 1200.docx
Exhibit 1201.docx
Exhibit 1202.docx
Exhibit 1203.docx
etc.
Thanks for your fast help.
Regards,
Armstrong
Armstrong
-
- Administrator
- Posts: 78506
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Extract Partial File Name
"to extract and print the 4 digits from the filenames"
Does that mean that you want to process all docx files in a folder?
Does that mean that you want to process all docx files in a folder?
Best wishes,
Hans
Hans
-
- 2StarLounger
- Posts: 105
- Joined: 19 Apr 2010, 10:25
- Location: Hong Kong
Re: Extract Partial File Name
Nope. It's much simpler. Just display the 4 digits of a docx file. It's intended as a cover sheet. Because there are many exhibits, manually typing the 4 digits is tideous and error-prone.
Regards,
Armstrong
Armstrong
-
- 4StarLounger
- Posts: 508
- Joined: 17 Dec 2010, 03:14
Re: Extract Partial File Name
Hi Armstrong,
Since it's only the digits you're after, use a nested field coded as:
{={FILENAME} \# 0000}
Since it's only the digits you're after, use a nested field coded as:
{={FILENAME} \# 0000}
Paul Edstein
[Fmr MS MVP - Word]
[Fmr MS MVP - Word]
-
- 2StarLounger
- Posts: 105
- Joined: 19 Apr 2010, 10:25
- Location: Hong Kong
Re: Extract Partial File Name
Hi Paul,
Thanks for your help. We're very close to the solution. For the Exhibit 1200.docx,
{={FILENAME} \# 0000} produces an error: !Syntax Error, 1200.
And why does it produce the period at the end?
At least it's the first time the doc filename can actually be manipuated.
Please help. Thanks.
Thanks for your help. We're very close to the solution. For the Exhibit 1200.docx,
{={FILENAME} \# 0000} produces an error: !Syntax Error, 1200.
And why does it produce the period at the end?
At least it's the first time the doc filename can actually be manipuated.
Please help. Thanks.
Regards,
Armstrong
Armstrong
-
- Administrator
- Posts: 78506
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Extract Partial File Name
Paul, I have a document named Doc 1234.docm.
I insert the following fields (field codes displayed):
The result after hiding the field codes and updating the fields is:
It does extract the number, but not quite in the way intended.
(I'm using Word 2010 SP1)
I insert the following fields (field codes displayed):
The result after hiding the field codes and updating the fields is:
It does extract the number, but not quite in the way intended.
(I'm using Word 2010 SP1)
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- 2StarLounger
- Posts: 105
- Joined: 19 Apr 2010, 10:25
- Location: Hong Kong
Re: Extract Partial File Name
Actually, Paul's solution works with a minor modification:
{quote {filename} \# 0000 }
Paul & hans, thanks for your help.
{quote {filename} \# 0000 }
Paul & hans, thanks for your help.
Regards,
Armstrong
Armstrong