MSOffice Programming (Word) help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • steven chong

    MSOffice Programming (Word) help

    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.Applicatio n()
    objWord.Documen ts.Open("C:\bef ore.doc")
    objWordDocument = objWord.ActiveD ocument
    With objWordDocument
    .Range.InsertFi le("C:\Word\Bla h\File1.doc")
    .Range.MoveEnd( )
    .Range.Collapse (0)
    .Range.InsertBr eak(7)
    .Range.InsertFi le("C:\Word\Bla h\File2.doc")
    .SaveAs("C:\aft er.doc")
    End With

    thanks in advance

  • Cindy Meister  -WordMVP-

    #2
    Re: MSOffice Programming (Word) help

    Hi Steven,
    [color=blue]
    > 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
    >[/color]
    Try

    objWord = New Word.Applicatio n()
    objWord.Documen ts.Open("C:\bef ore.doc")
    objWordDocument = objWord.ActiveD ocument
    With objWordDocument
    .Range.InsertFi le("C:\Word\Bla h\File1.doc")
    .Range.Collapse (0)
    .Range.InsertBr eak(7)
    .Range.Collapse (0)
    .Range.InsertFi le("C:\Word\Bla h\File2.doc")
    .SaveAs("C:\aft er.doc")
    End With


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


    This reply is posted in the Newsgroup; please post any follow question or
    reply in the newsgroup and not by e-mail :-)

    Comment

    Working...