Results 1 to 5 of 5
  1. #1
    5 Star Lounger Lugh's Avatar
    Join Date
    Jun 2010
    Location
    Indy
    Posts
    627
    Thanks
    168
    Thanked 77 Times in 68 Posts

    W16 INCLUDETEXT behavior and syntax

    I'm building documents from component parts. The parts are entire files [ie no bookmarks] brought into each doc via the INCLUDETEXT field. I'm experiencing some weird behavior which neither my fiddling nor reading around has solved. Word 2016 on Win10, all text is docx or docm.

    The same custom template is used for both parts and docs, all formatting is via styles, same styles used in parts and docs. Template and styles are both isolated from Normal.

    The parts supply maybe 1/3 of the doc, the rest is unique external content.

    Behavior

    Problem is that one of the nine includes in the doc has been flaky from the start, and now a second include has become similarly flaky also. Flaky means that in code view, the field is split in two by its content. Example:

    Source for inclusion - D:\Docs\FredFlintstone.docx
    Source content - Frederick "Rocky" Flinstone, esq.

    Target doc code view -
    { INCLUDETEXT "D:\\Docs\\FredFlintstoneFrederick "Rocky" Flinstone, esq.
    .docx"}

    It's the same 'split in two' in each case, the .docx"} shunted to the end after the text. One include is only 2-3 lines, the other is 5-6 pages.
    So I made a couple of changes to the template, and built the doc again from scratch. Same include failed again, this time only docx"} got shunted to the end--ie the 'dot' stayed with the first part of the path. After I delete the content from code view, the final brace goes onto its own line, like:
    { INCLUDETEXT "D:\\Docs\\FredFlintstone.docx"
    }

    I'm new to this so I hope someone can point out the gotcha, or at least point me in the direction to go. Maybe INCLUDETEXT is just buggy, altho it's been around so long I'd have expected it to be stable by now. Are there some 'best practices' or tips to minimize instability?

    Syntax

    My template has a couple of small pieces of boiler text, the rest is INCLUDETEXT calls to dummy files in the relevant folders. The dummies contain only snippets like "Insert name here".
    I deleted various superfluous spaces in the code, but that doesn't seem to change anything. Example, I changed
    { INCLUDETEXT "D:
    to
    {INCLUDETEXT"D:

    To assemble a doc, I copy the unique content [after a separate cleaning routine] into a new doc based on my template. In code view, I then edit the dummy filenames to real ones.
    This is when Alt-F9 reveals the bad news.

    Thanks for any pointers.
    Lugh.
    ~
    Windows 10 Pro x64 1607; Office 2016 (365 Home) x32; Win Defender, MBAM Pro

    ASRock H97 Anniversary; Xeon E3-1231V3 (like i7)
    Gigabyte GeForce GTX 970; 12GB Crucial DDR3 1600
    Logitech MX Master mouse; Roccat Isku kb

  2. #2
    Star Lounger Graham Mayor's Avatar
    Join Date
    Mar 2016
    Location
    Cyprus
    Posts
    69
    Thanks
    0
    Thanked 24 Times in 24 Posts
    The syntax - { INCLUDETEXT "D:\\Docs\\FredFlintstoneFrederick "Rocky" Flinstone, esq.
    .docx"} is wrong. You can't have a line break in the middle of a filename. In any case your message suggests the filename is D:\Docs\FredFlintstone.docx
    so the correct syntax is { INCLUDETEXT "D:\\Docs\\FredFlintstone.docx" }. Ensure that there is nothing else between the field brackets. The file must of course exist at that location.
    Graham Mayor - Word MVP
    http://www.gmayor.com

  3. #3
    5 Star Lounger Lugh's Avatar
    Join Date
    Jun 2010
    Location
    Indy
    Posts
    627
    Thanks
    168
    Thanked 77 Times in 68 Posts
    Thanks Graham.
    Quote Originally Posted by Graham Mayor View Post
    The syntax ... is wrong. You can't have a line break in the middle of a filename.
    Sorry my post wasn't clear, the syntax you mention isn't mine, it's the result which Word gives me after updating fields--ie it shows both the code and the content mixed together, totally weird. I have the correct syntax, same syntax which works for all the other includes in the doc.

    your message suggests the filename is D:\Docs\FredFlintstone.docx
    Yes, that's the filename, and the content it contains is "Frederick "Rocky" Flinstone, esq."

    so the correct syntax is { INCLUDETEXT "D:\\Docs\\FredFlintstone.docx" }
    Yes, that's the syntax I'm using.

    It all worked as expected for 8 of the 9 includes, as I said. Just one resulted in this bad behavior. After some fiddling, a second include then went similarly bad--but the other 7 continued to work as expected.

    Solution / Workaround

    I beat this to death for 2-3 days, trying far too many things to even remember, never mind list here. Recreating the source and target docs completely from scratch, making various changes to the template, etc.

    What I finally got to work--so far I've created 10 new docs, each with 9 includes--is this:

    - Eliminate the dummy includes from the template, and build each target doc via manually inserting each of the 9 includes from the Insert > Object menu;
    - Do not use a macro to update all fields, do it via right-click instead.

    This works. However, it has still broken a couple of times when I changed content in one of the source files and then updated the field in the target doc. Workaround for that is to delete the include from the target doc and insert it anew again via the menu.

    So I have a working setup. However I'm not able to use a fast template-based method to create the target doc, and more importantly it seems like I've lost the facility to reliably auto-update the target when source content changes. The latter is a considerable efficiency setback.

    When I get past this current creation spike, I'll try reinstalling Word 2016 and see if that helps.
    Lugh.
    ~
    Windows 10 Pro x64 1607; Office 2016 (365 Home) x32; Win Defender, MBAM Pro

    ASRock H97 Anniversary; Xeon E3-1231V3 (like i7)
    Gigabyte GeForce GTX 970; 12GB Crucial DDR3 1600
    Logitech MX Master mouse; Roccat Isku kb

  4. #4
    Star Lounger Graham Mayor's Avatar
    Join Date
    Mar 2016
    Location
    Cyprus
    Posts
    69
    Thanks
    0
    Thanked 24 Times in 24 Posts
    Re-installing rarely achieves anything useful as the core program is rarely the problem. You would do better to rename the normal template, check your add-ins and ensure that there are no orphan lock files - see http://www.gmayor.com/what_to_do_when_word_crashes.htm
    Graham Mayor - Word MVP
    http://www.gmayor.com

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

    Lugh (2016-07-30)

  6. #5
    5 Star Lounger Lugh's Avatar
    Join Date
    Jun 2010
    Location
    Indy
    Posts
    627
    Thanks
    168
    Thanked 77 Times in 68 Posts
    Thanks for the direction Graham, I'll see how that goes.
    Lugh.
    ~
    Windows 10 Pro x64 1607; Office 2016 (365 Home) x32; Win Defender, MBAM Pro

    ASRock H97 Anniversary; Xeon E3-1231V3 (like i7)
    Gigabyte GeForce GTX 970; 12GB Crucial DDR3 1600
    Logitech MX Master mouse; Roccat Isku kb

Tags for this Thread

Posting Permissions

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