Results 1 to 5 of 5
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    InsertFile fails with a .. Bookmark

    More strangeness from Word97SR2/VBA.

    The document exists.

    The bookmark name exists in the document (it was generated by Word97 and satisfies itself when I choose Edit, Bookmark, GoTo.

    If boolInclude is true, the first InsertFile fails with a RunTime error 4198.

    If boolInclude is false, the second InsertFile succeeds.


    <pre> If boolInclude Then
    Selection.InsertFile FileName:=strDocName, Range:=strBKName, LINK:=True
    Else
    Selection.InsertFile FileName:=strDocName, Range:=strBKName, LINK:=False
    End If


    Here's a snippet from the Immediate Window:

    ?"|" & strBKName & "|"
    |new template|

    </pre>


  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: InsertFile fails with a .. Bookmark

    How about a little more detail. What's a 4198 in English? Also what is the value of strBKName on the true condition?
    Also, where's the debug.print statement? I'd like to see what's on that line.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: InsertFile fails with a .. Bookmark

    > What's a 4198 in English?

    I don't know. It's late and I can't find my listing of error codes. I know it's here. It got in the way last week.


    > Also what is the value of strBKName on the true condition?

    Same as for the false: "new template" without the quotes. I believe it is the space that triggers the error.

    > Also, where's the debug.print statement? I'd like to see what's on that line.

    I didn't use debug.print. I typed a question mark in the Immediate Window.



    I'm not sure that there's a solution to this. I posted it more as a "beware" notice. I collect the path, file and bookmark from a listbox. If I double-click on the listbox the thing flip-flops from "paste" to "link" and back again. That's how i tripped over this. The darn thing worked (got my bookmarked text brought in) and then ten seconds later it didn't work.

    I figure two different guys wrote the code.

  4. #4
    kelliel
    Guest

    Re: InsertFile fails with a .. Bookmark

    As you can see, I am reading some back message threads. Came across this one.

    I tried the following in the Intermediate Window (obviously without the next line extenders, is that the correct term for them?), and there was no problem:

    <pre> Selection.InsertFile FileName:="C:My Documentsdoc1.doc", _
    Range:=Activedocument.Bookmarks("add").Range.Text, _
    link:=true</pre>


    Does this help at all?

    Also, you may want to check out this Knowledge Base article, may have something of interest to you. Whereas it doesn't specifically address your context, there may be something that you may find useful.

    Oh, almost forgot. I, too, am using Word 97 sr2.

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: InsertFile fails with a .. Bookmark

    You got me. I can't remember whether I solved the problem or not. I have filed your thoughtful response in the ap folder for Under-the-hood (productsunder). It seems to me the problem arose when I was cleaning up that template, so it'll have to wait until the next go-round.


    Ypu will have noted (Kevin, was it)'s question "what is a 4198". Your KB article indicates that the '4198' code might have been used in several different circumstances. I hope they fired whoever was assigning serial error numbers that week.



    In some cases I get a problem/question that's not life-threatening, and/or quickly devise a work-around. I'll post my trivial problem here anyway, just in case someone else is about to bash THEIR head against a brick wall. I figure alerting others to quirks gives them a chance to establish contact before too much time is wasted.

    As an example, if your post had read "I've just got this and I need to fix it", I'd feel it worthwhile to dig out my original problem and the two of us solve it together; for myself it might be no immediate big deal. I hope that makes sense.


    I thank you for turning over the compost heap and seeing the worms.

    Which reminds me, if the sun shines today, I might get to play outside ...

Posting Permissions

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