Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Wendy V
 
Posts: n/a
Default Insert part of Filename in Header

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
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
 
Posts: n/a
Default Insert part of Filename in Header


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



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

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




  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
 
Posts: n/a
Default Insert part of Filename in Header

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






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

I figured out that if I put the field in a text box, it the field displays
properly. I then overlayed the text box on top of the position in the table
where I need the resulting field information. Works great.

Thanks for your help!

"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








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

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






  #7   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
 
Posts: n/a
Default Insert part of Filename in Header

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








  #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









Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Eliminate a horizontal line (part of the header) on every page? dvshark Microsoft Word Help 2 January 4th 06 05:23 AM
Insert tomorrow's date into header alex84 Microsoft Word Help 1 October 19th 05 12:08 AM
how to insert custom footer as part of firing print command iamvik Microsoft Word Help 5 September 15th 05 01:34 AM
Insert Header Row In Table During Merge Michael Koerner Mailmerge 4 April 16th 05 04:34 PM
How do I insert and format part of a data field in a Word document Graham Blundell Microsoft Word Help 4 December 1st 04 03:51 PM


All times are GMT +1. The time now is 07:28 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"