DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Inserting other Word Documents into a Word Document

  1. #1
    Chole Guest

    Inserting other Word Documents into a Word Document


    Hi,

    I am inserting Word Documents (stored in an SQL DB) into a Word Document
    at certain Bookmarks on the document. I have no problem retrieving the documents
    and inserting them into the Word Document at a certain Bookmark.

    Here is how I am doing that:

    Selection.GoTo what:=wdGoToBookmark, Name:="BMHeader"
    strAdoc = "StateReg.doc"
    strCompID = "6"
    Call RetrieveDoclet(strAdoc, strCompID)
    Selection.InsertFile FileName:=strAdoc


    Selection.GoTo what:=wdGoToBookmark, Name:="BMHeader"
    strAdoc = "RevCanReg.doc"
    strCompID = "7"
    Call RetrieveDoclet(strAdoc, strCompID)
    Selection.InsertFile FileName:=strAdoc


    Selection.GoTo what:=wdGoToBookmark, Name:="BMHeader"
    strAdoc = "CalcDate.doc"
    strCompID = "8"
    Call RetrieveDoclet(strAdoc, strCompID)
    Selection.InsertFile FileName:=strAdoc


    My problem is the order that the three documents are placed in the document.
    Looking at my code the document should appear as such:
    At Bookmark 'BMHeader' I should see First "SateReg.doc"
    Second "RevUSReg.doc"
    Third "CalcDate.doc"

    But instead the documents are placed First "CalcDate.doc"
    Second "RevUSReg.doc"
    Third "SateReg.doc"

    What can I do in my code to place a document at the bookmark and then drop
    down a line to place the next document at the same bookmark but below the
    one previously placed document and NOT above the one previously placed document
    thus eliminating my problem.


  2. #2
    Arthur Wood Guest

    Re: Inserting other Word Documents into a Word Document


    Chole,
    Try commenting out the Second and Third instances of

    Selection.GoTo what:=wdGoToBookmark, Name:="BMHeader"

    Those two entries are moving you BACK to that Bookmark in your document,
    and then inserting at the point.

    Alternatively, simply reverse the order of the Documents that you are inserting
    (keeping the lines - "Selection.GoTo what:=wdGoToBookmark, Name:="BMHeader""
    as they are), so that you would insert CalcDate.Doc FIRST, RevCanReg.doc
    SECOND and StateReg.doc THIRD, and they would then APPEAR in the "correct"
    order in the resulting document.

    Arthur Wood



    "Chole " <cholemarissatolebero@hotmail.com> wrote:
    >
    >Hi,
    >
    >I am inserting Word Documents (stored in an SQL DB) into a Word Document
    >at certain Bookmarks on the document. I have no problem retrieving the documents
    >and inserting them into the Word Document at a certain Bookmark.
    >
    >Here is how I am doing that:
    >
    > Selection.GoTo what:=wdGoToBookmark, Name:="BMHeader"
    > strAdoc = "StateReg.doc"
    > strCompID = "6"
    > Call RetrieveDoclet(strAdoc, strCompID)
    > Selection.InsertFile FileName:=strAdoc
    >
    >
    > Selection.GoTo what:=wdGoToBookmark, Name:="BMHeader"
    > strAdoc = "RevCanReg.doc"
    > strCompID = "7"
    > Call RetrieveDoclet(strAdoc, strCompID)
    > Selection.InsertFile FileName:=strAdoc
    >
    >
    > Selection.GoTo what:=wdGoToBookmark, Name:="BMHeader"
    > strAdoc = "CalcDate.doc"
    > strCompID = "8"
    > Call RetrieveDoclet(strAdoc, strCompID)
    > Selection.InsertFile FileName:=strAdoc
    >
    >
    >My problem is the order that the three documents are placed in the document.
    >Looking at my code the document should appear as such:
    >At Bookmark 'BMHeader' I should see First "SateReg.doc"
    > Second "RevUSReg.doc"
    > Third "CalcDate.doc"
    >
    >But instead the documents are placed First "CalcDate.doc"
    > Second "RevUSReg.doc"
    > Third "SateReg.doc"
    >
    >What can I do in my code to place a document at the bookmark and then drop
    >down a line to place the next document at the same bookmark but below the
    >one previously placed document and NOT above the one previously placed document
    >thus eliminating my problem.
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center