View Single Post
  #8   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Wendy V
 
Posts: n/a
Default Insert part of Filename in Header

Thank you, thank you! that link to the MS article did the trick.

"Peter Jamieson" wrote:

Two possibilities off the top of my head:
a. a lot of fields behave differently in text boxes (if they behave at all)
b. it could be to do with the security-related registry settings described
in

http://support.microsoft.com/kb/330554/en-us

which also apply to Word 2003 (except you need to adjust the version numbers
in the relevant registry paths.

Peter Jamieson
"Wendy V" wrote in message
...
Just wondering if you know why this field (in the text box) will not
update
unless I manually press F9. I have "Update Fields" selected in Options. Do
I
need to use a macro? If so, how would I capture the "Save" event and
update
just before the save? ( I wasn't sure if I should post this question in
another forum or in this one for continuity.)

Thanks,
Wendy

"Peter Jamieson" wrote:

Yes, it won't work in a table. I don't know why. But it works in a header
(as per your original post). Can a table be avoided?

Peter Jamieson

"Wendy V" wrote in message
...
Peter,

Thanks so much for responding to my post and I apologize for the late
response.

I tried the .mdb method and it worked great when the field was inserted
in
the main body of my document. However, I when I inserted the field into
a
table I received the following error: "Error! Not a valid result for
table."
Is there any way to fix this error (other than not inserting the field
in
a
table) or is this just a limitiation of Word?

Thanks
Wendy

"Peter Jamieson" wrote:


If the name of the document is being set up by a macro at some point,
i.e.
not on the user's machine, you should consider creating a Document
Property
or Document Variable containing the text you want,and use a {
DOCPROPERTY }
or { DOCVARIABLE } field to insert it in the header. NB, in older
versions
of Word, { DOCVARIABLE } fields in the header used to crash Word.

Otherwise, it may be possible to do this but there are so many gotchas
that
using a macro is probably safer and easier (and I say that with some
reluctance).

Precisely how to do it depends on the version of Word. In the current
version of Word 2003, you can get away with the following:

Create a .mdb file (if you don't have Access, you can create one by
creating
a new mail merge list which is just a .mdb with a special format) or a
.xls
file. There are other possibilities but this is the simplest approach.
Let's
say you created c:\a\a.mdb.

Then insert the following nested field in your header

{ DATABASE \d "C:\\a\\a.mdb" \s "SELECT left('{ FILENAME }',instr('{
FILENAME } ',' ')-1)" }

(All the {} have to be the special field braces you can insert using
ctrl-F9, and all the single quotes need to be straight quotes. Note
also
the
doubled up backslashes in the file name, and the fact that there is a
space
after the second { FILENAME } in case the filename has no spaces)

Gotchas include:
a. You have to distribute the .mdb But you do only need /one/ dummy
.mdb
for all such applications.
b. The user may face security-related dialogs
c. If there are ever any single-quote characters in the filename, the
field
will fail.

Peter Jamieson
"Wendy V" wrote in message
...
Is it possible to insert only part of a file name into the header? I
have
a
document named "HSE-I.1-001-P HS&E Manual.doc" and I would like to
insert
a
field that would display "HSE-I.1-001-P". I know I could accomplish
this
using VBA but don't want the user to have to "enable macros" when
they
open
the document. If I could insert this function:
mid(FILENAME,1,instr(FILENAME," ")) into the header it would
accomplish
what
I want to do.

If anyone could offer any suggestions, I would really appreciate it.

Thanks,
Wendy