Results 1 to 15 of 15
  1. #1
    New Lounger
    Join Date
    Sep 2014
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Problem with Word field codes

    Hi,

    I have a master document template with INCLUDETEXT fields for each sub documents.

    As its for a monthly report, all documents will be copied to new folder every month. I have created custom docproperty for master location and have used that in INCLUDETEXT.

    {INCLUDETEXT "{DOCPROPERTY MasterLocation \p}"/../ExecutiveSummary.docx"}
    {INCLUDETEXT "{DOCPROPERTY MasterLocation \p}"/../ServiceDeskSummary.docx"}

    When I try to update the fields(F9), DOCPROPERTY is converting to plain text and getting Error! Not a valid filename error.

    What am I doing wrong?

    Thanks,
    Jyothi

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Check the value of "{DOCPROPERTY MasterLocation \p} separately to ensure you are getting what you expect. I am not sure why you need the \p switch there. I also don't know why you would try to step back one folder by using the ../

    If the document is in the same folder and the target then a simple way would work
    {IncludeText "ExecutiveSummary.docx"}

    If you do need to point at a specific folder
    {IncludeText {Quote {DocProperty MasterLocation} "\ExecutiveSummary.docx" }}
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    New Lounger
    Join Date
    Sep 2014
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks Andrew.

    All sub documents are in the same folder as the master document. Master location is the folder path, where all these documents are saved.

    Both your solutions are not working. its only working with \P and /./

    {IncludeText "{DocProperty MasterLocation \P}/./\ExecutiveSummary.docx" }


    is it something to do with folder path?? All these documents are in a network folder.

    Another problem is page layout. Master page not keeping the page layout as the sub documents when updated. All sub documents got page and section breaks wherever required. Still I had to adjust the layout in Master.

    Thanks for you help.

    Jyothi

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Quote Originally Posted by JyothiYepuri View Post
    All sub documents are in the same folder as the master document. Master location is the folder path, where all these documents are saved.
    In that case there's no point in using the DOCPROPERTY field. Simply use an embedded FILENAME field, per:
    {INCLUDETEXT "{FILENAME \p}/../ExecutiveSummary.docx"}
    or:
    {INCLUDETEXT "{FILENAME \p}\\..\\ExecutiveSummary.docx"}
    Do note the two periods in the /../ and \\..\\ portions.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. The Following User Says Thank You to macropod For This Useful Post:

    Charles Kenyon (2014-09-12)

  6. #5
    New Lounger
    Join Date
    Sep 2014
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by macropod View Post
    In that case there's no point in using the DOCPROPERTY field. Simply use an embedded FILENAME field, per:
    {INCLUDETEXT "{FILENAME \p}/../ExecutiveSummary.docx"}
    or:
    {INCLUDETEXT "{FILENAME \p}\\..\\ExecutiveSummary.docx"}
    Do note the two periods in the /../ and \\..\\ portions.
    I have tried with FILENAME too. main problem is inner field is converting to plain text when document is updated and returning file not exists error.

    any ideas. Thanks

  7. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    That suggests you're just typing the {FILENAME \p} instead of using Ctrl-F9 to create the field braces for the FILENAME field.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  8. #7
    New Lounger
    Join Date
    Sep 2014
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    No. I am using Ctrl+F9 to create the inner field. Once document is updated, its no longer a field.

  9. #8
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    So what does the field code look like after it has updated?
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  10. #9
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    I would debug the issue by checking what the filename field resolves to independent of the outer field. Does the following give you what you expected? Do the slashes align with the text that you follow it with?

    {FILENAME \p}
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  11. #10
    New Lounger
    Join Date
    Sep 2014
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    {INCLUDETEXT {FILENAME \P}/../"executive summary.docx"}

    when I right click on FILENAME and select the option edit field, its opening dialog to edit INCLUDETEXT field

  12. #11
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    What happens if you copy the {FILENAME \P} from the INCLUDETEXT field, paste it somewhere else in the document, then do ctrl-A, F9?
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  13. #12
    New Lounger
    Join Date
    Sep 2014
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Nothing happening as its plain text.

  14. #13
    New Lounger
    Join Date
    Sep 2014
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Yes. {FILENAME \p} is working until I update the document using Ctrl-A and F9. After that all inner fields are converted to plain text.

    Also sometimes after update \p is updated to \\p.

  15. #14
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    All of this suggests either there is a fault with your Office installation or that you have a rogue 3rd-party addin that is messing with the fields.

    Try repairing the Office installation (via Programs & Features > Microsoft Office > Change in the Windows Control Panel). If the problem persists, test by running Word in safe mode. If the problem doesn't appear in safe mode, it's a rogue 3rd-party addin that is messing with the fields.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  16. The Following User Says Thank You to macropod For This Useful Post:

    JyothiYepuri (2014-09-16)

  17. #15
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    I assume that you are not pressing Ctrl-Shift-F9 when the fields are selected. This would convert the field result to plain text.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •