word automation find and replace

Discussion in 'ASP .Net' started by James Vitale, Sep 16, 2005.

  1. James Vitale

    James Vitale Guest

    Using vb asp.net 1.1

    I'm doing a word automation on a doc file and trying to do a find and
    replace. My existing code works fine except that it doesn't find and
    replace in the header.

    My code to set the selection is as follows:

    'This sets the selection to be the whole document

    wordApp.Selection.HomeKey(Word.WdUnits.wdStory, Word.WdMovementType.wdMove)

    ' Select from the insertion point to the end of the document.

    wordApp.Selection.EndKey(Word.WdUnits.wdStory, Word.WdMovementType.wdExtend)


    I then loop through and do a find and replace using
    wordApp.Selection.Find.Execute

    My problem is, it doesn't Find and Replace in the header and footer. Any
    idea on the syntax to automate find and replace there?

    Thanks,

    James
     
    James Vitale, Sep 16, 2005
    #1
    1. Advertising

  2. Hi James

    Nice to know someone else is automating word with asp.net!

    I haven't done header/footer myself but there should be something in the
    following search results page that will help ya...

    http://www.pillage.com/search/Word_VBA_Header_and_Footer.html

    Cheers


    Dan



    "James Vitale" wrote:

    > Using vb asp.net 1.1
    >
    > I'm doing a word automation on a doc file and trying to do a find and
    > replace. My existing code works fine except that it doesn't find and
    > replace in the header.
    >
    > My code to set the selection is as follows:
    >
    > 'This sets the selection to be the whole document
    >
    > wordApp.Selection.HomeKey(Word.WdUnits.wdStory, Word.WdMovementType.wdMove)
    >
    > ' Select from the insertion point to the end of the document.
    >
    > wordApp.Selection.EndKey(Word.WdUnits.wdStory, Word.WdMovementType.wdExtend)
    >
    >
    > I then loop through and do a find and replace using
    > wordApp.Selection.Find.Execute
    >
    > My problem is, it doesn't Find and Replace in the header and footer. Any
    > idea on the syntax to automate find and replace there?
    >
    > Thanks,
    >
    > James
    >
    >
    >
     
    =?Utf-8?B?ZGhucml2ZXJzaWRl?=, Sep 16, 2005
    #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. rynox
    Replies:
    4
    Views:
    29,077
    Malte
    Nov 18, 2005
  2. Jordan
    Replies:
    1
    Views:
    659
    Mark Rae
    Dec 12, 2006
  3. apondu
    Replies:
    0
    Views:
    600
    apondu
    Jul 19, 2007
  4. Replies:
    3
    Views:
    239
    Lawrence D'Oliveiro
    Apr 1, 2009
  5. Michael G. Schneider

    Modifying a Word document without using Word Automation

    Michael G. Schneider, Dec 15, 2003, in forum: ASP General
    Replies:
    5
    Views:
    285
    el.c. - myLittleTools.net
    Dec 16, 2003
Loading...

Share This Page