Consulting

Results 1 to 4 of 4

Thread: Solved: File insert creates an unwanted field

  1. #1
    VBAX Newbie
    Joined
    Jul 2005
    Posts
    2
    Location

    Solved: File insert creates an unwanted field

    Hi,

    I have written a script to automate the creation of several documents. These documents were already written and I have resaved them into a template file with the appropriate bookmarks for code insertion etc. This all works like a charm.

    The problem is that when I insert the template into a new document, a field is generated in the footer of the first page. However this field does not exist in the template (as far as i can tell), and it always resolves into an ugly error:
    "Error! Unknown document property name."
    across the bottom of all of the documents. When I click reveal code it shows the following:
    { if { docproperty mDocID } = "" "{FILENAME \p}" "{docproperty mDocID \* charFORMAT}" }

    The following snippet of code shows the insert occuring:

    ' Create a new document
    Documents.Add DocumentType:=wdNewBlankDocument

    ChangeFileOpenDirectory "C:\autoDOC\templates\"

    ' Insert the template file into the new document
    Selection.InsertFile FileName:=docType & ".dot"

    How can I prevent this field from being inserted into the document?? is there some magical setting that i have missed in the template file - because this only occurs with some of the template files.

    Thanks,
    Ryan

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi and Welcome to VBAX!

    There's nothing wrong with that code and I'm sure that the code is not causing the problem.

    The insertfile method also takes in the headerfooter from the document to be inserted.

    So can you please open that document manualy and go to header footer. Press ALT+F9 to see if those fields are in there as well.

    If not could you please attach that document (Which you want to insert) here stripped of private stuff so we can examine it.

    This must be in the template or document to be inserted cause otherwise it wouldn't make sence.

    HTH,
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  3. #3
    VBAX Newbie
    Joined
    Jul 2005
    Posts
    2
    Location
    Thx for the welcome,

    I managed to solve the problem - it was a custom document property that was added in by the lawyers system when they reviewed the document. I was able to remove it fairly easily. Thanks for the prompt response anyway.

    Cheers,
    Ryan

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi Ryan,

    You're most welcome!
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

Posting Permissions

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