MSOffice Programming (Word) help

Discussion in 'ASP .Net' started by steven chong, Oct 1, 2003.

  1. steven chong

    steven chong Guest

    Hi everyone,
    Hope the MVPs for Office can help me out here.
    Programming the word object is new to me. Basically, what i need to do is...
    1) Open a template word document.
    2) Menu->Insert->File (Another word Document)
    3) Page Break
    4) Repeat Step 2 for another file
    5) Page Break
    6) Save

    i was succesfully in Inserting the new WordFile, but cant page break and
    insert the next file. i always only get the latest file which i inserted
    as the final product.
    any samples, links which i can refer to will be very helpful

    what i have now:

    objWord = New Word.Application()
    objWord.Documents.Open("C:\before.doc")
    objWordDocument = objWord.ActiveDocument
    With objWordDocument
    .Range.InsertFile("C:\Word\Blah\File1.doc")
    .Range.MoveEnd()
    .Range.Collapse(0)
    .Range.InsertBreak(7)
    .Range.InsertFile("C:\Word\Blah\File2.doc")
    .SaveAs("C:\after.doc")
    End With

    thanks in advance
    steven chong, Oct 1, 2003
    #1
    1. Advertising

  2. Hi Steven,

    > Hope the MVPs for Office can help me out here.
    > Programming the word object is new to me. Basically, what i need to do is...
    > 1) Open a template word document.
    > 2) Menu->Insert->File (Another word Document)
    > 3) Page Break
    > 4) Repeat Step 2 for another file
    > 5) Page Break
    > 6) Save
    >
    > i was succesfully in Inserting the new WordFile, but cant page break and
    > insert the next file. i always only get the latest file which i inserted
    > as the final product.
    > any samples, links which i can refer to will be very helpful
    >

    Try

    objWord = New Word.Application()
    objWord.Documents.Open("C:\before.doc")
    objWordDocument = objWord.ActiveDocument
    With objWordDocument
    .Range.InsertFile("C:\Word\Blah\File1.doc")
    .Range.Collapse(0)
    .Range.InsertBreak(7)
    .Range.Collapse(0)
    .Range.InsertFile("C:\Word\Blah\File2.doc")
    .SaveAs("C:\after.doc")
    End With


    Cindy Meister
    INTER-Solutions, Switzerland
    http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
    http://www.mvps.org/word

    This reply is posted in the Newsgroup; please post any follow question or
    reply in the newsgroup and not by e-mail :)
    Cindy Meister -WordMVP-, Oct 3, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Laura
    Replies:
    1
    Views:
    514
    Gunnar Hjalmarsson
    Jun 5, 2004
  2. steven chong

    MSOffice Programming (Word) help

    steven chong, Oct 1, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    391
    Cindy Meister -WordMVP-
    Oct 3, 2003
  3. S.Kartikeyan

    MSOffice and ASP.NET

    S.Kartikeyan, Mar 4, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    454
    S.Kartikeyan
    Mar 5, 2004
  4. MSoffice metadata

    , Jun 25, 2006, in forum: Python
    Replies:
    3
    Views:
    387
    Roger Upole
    Jun 27, 2006
  5. srinivas
    Replies:
    1
    Views:
    74
Loading...

Share This Page