Word 2003 Find/Change Automation from Excel 2003 crashes Excel 200

Discussion in 'Microsoft Excel Programming' started by Guest, Mar 2, 2006.

  1. Guest

    Guest Guest

    I just upgraded to Office Professional 2003 from Office Professional XP.

    The following code, when executed, completely and irrevocably crashes
    Microsoft Excel 2003 at the line <.Text = "^pDescription">. It worked just
    find in Microsoft Excel XP. It even asks to send a report to Microsoft. Every
    time. Easily reproducible. I have updated to all service packs/patches, etc.,
    too.

    Also, the line <Selection.Find.Replacement.ClearFormatting> gives a
    "Automation error: the procedure number is out of range" error, which it
    didn't do before in Excel 2003.

    What the heck happened between the two versions? Now my code has completely
    blown up!!! Any ideas????? Any help would be greatly appreciated, as we have
    to get this program up and running for production! Thanks!!!

    Public Sub Test()
    Dim appWord As Word.Application

    Set appWord = New Word.Application
    appWord.Documents.Add

    appWord.Selection.Find.ClearFormatting
    appWord.Selection.Find.Replacement.ClearFormatting
    With appWord.Selection.Find
    .Text = "^pBREAK"
    .Replacement.Text = "-----"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    appwordSelection.Find.Execute Replace:=wdReplaceAll

    appWord.ActiveDocument.SaveAs "C:\TEST.DOC"
    appWord.ActiveDocument.Close
    appWord.Quit

    Set appWord = Nothing

    End Sub
     
    Guest, Mar 2, 2006
    #1
    1. Advertisements

  2. Guest

    Tom Ogilvy Guest

    There is no line

    <.Text = "^pDescription">

    regardless,
    since all of this is performing actions in word, why not ask in a word group
    where you may have a higher probability of reaching someone who knows about
    the word object model.

    --
    Regards,
    Tom Ogilvy


    "Joel Berry" <> wrote in message
    news:...
    > I just upgraded to Office Professional 2003 from Office Professional XP.
    >
    > The following code, when executed, completely and irrevocably crashes
    > Microsoft Excel 2003 at the line <.Text = "^pDescription">. It worked just
    > find in Microsoft Excel XP. It even asks to send a report to Microsoft.

    Every
    > time. Easily reproducible. I have updated to all service packs/patches,

    etc.,
    > too.
    >
    > Also, the line <Selection.Find.Replacement.ClearFormatting> gives a
    > "Automation error: the procedure number is out of range" error, which it
    > didn't do before in Excel 2003.
    >
    > What the heck happened between the two versions? Now my code has

    completely
    > blown up!!! Any ideas????? Any help would be greatly appreciated, as we

    have
    > to get this program up and running for production! Thanks!!!
    >
    > Public Sub Test()
    > Dim appWord As Word.Application
    >
    > Set appWord = New Word.Application
    > appWord.Documents.Add
    >
    > appWord.Selection.Find.ClearFormatting
    > appWord.Selection.Find.Replacement.ClearFormatting
    > With appWord.Selection.Find
    > .Text = "^pBREAK"
    > .Replacement.Text = "-----"
    > .Forward = True
    > .Wrap = wdFindContinue
    > .Format = False
    > .MatchCase = False
    > .MatchWholeWord = False
    > .MatchWildcards = False
    > .MatchSoundsLike = False
    > .MatchAllWordForms = False
    > End With
    > appwordSelection.Find.Execute Replace:=wdReplaceAll
    >
    > appWord.ActiveDocument.SaveAs "C:\TEST.DOC"
    > appWord.ActiveDocument.Close
    > appWord.Quit
    >
    > Set appWord = Nothing
    >
    > End Sub
    >
     
    Tom Ogilvy, Mar 2, 2006
    #2
    1. Advertisements

  3. Guest

    Guest Guest

    Re: Word 2003 Find/Change Automation from Excel 2003 crashes Excel

    Thanks, Tom.

    You're right. The line is the "^pBREAK" line. I was testing it again with a
    different text to find. So, the line that is causing the crash is the ".Text
    = ^pBREAK" line.

    The reason I posted it here is because it works flawlessly in Word 2003.
    It's when you call it from a Word.Application object from within Excel that
    it crashes. So, it's not necessarily a Word problem. Make sense?

    "Tom Ogilvy" wrote:

    > There is no line
    >
    > <.Text = "^pDescription">
    >
    > regardless,
    > since all of this is performing actions in word, why not ask in a word group
    > where you may have a higher probability of reaching someone who knows about
    > the word object model.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Joel Berry" <> wrote in message
    > news:...
    > > I just upgraded to Office Professional 2003 from Office Professional XP.
    > >
    > > The following code, when executed, completely and irrevocably crashes
    > > Microsoft Excel 2003 at the line <.Text = "^pDescription">. It worked just
    > > find in Microsoft Excel XP. It even asks to send a report to Microsoft.

    > Every
    > > time. Easily reproducible. I have updated to all service packs/patches,

    > etc.,
    > > too.
    > >
    > > Also, the line <Selection.Find.Replacement.ClearFormatting> gives a
    > > "Automation error: the procedure number is out of range" error, which it
    > > didn't do before in Excel 2003.
    > >
    > > What the heck happened between the two versions? Now my code has

    > completely
    > > blown up!!! Any ideas????? Any help would be greatly appreciated, as we

    > have
    > > to get this program up and running for production! Thanks!!!
    > >
    > > Public Sub Test()
    > > Dim appWord As Word.Application
    > >
    > > Set appWord = New Word.Application
    > > appWord.Documents.Add
    > >
    > > appWord.Selection.Find.ClearFormatting
    > > appWord.Selection.Find.Replacement.ClearFormatting
    > > With appWord.Selection.Find
    > > .Text = "^pBREAK"
    > > .Replacement.Text = "-----"
    > > .Forward = True
    > > .Wrap = wdFindContinue
    > > .Format = False
    > > .MatchCase = False
    > > .MatchWholeWord = False
    > > .MatchWildcards = False
    > > .MatchSoundsLike = False
    > > .MatchAllWordForms = False
    > > End With
    > > appwordSelection.Find.Execute Replace:=wdReplaceAll
    > >
    > > appWord.ActiveDocument.SaveAs "C:\TEST.DOC"
    > > appWord.ActiveDocument.Close
    > > appWord.Quit
    > >
    > > Set appWord = Nothing
    > >
    > > End Sub
    > >

    >
    >
    >
     
    Guest, Mar 2, 2006
    #3
  4. Guest

    Tom Ogilvy Guest

    Re: Word 2003 Find/Change Automation from Excel 2003 crashes Excel

    Did it work the first time you ran it? Then develop problems.
    Look in the task manager and see if you have multiple versions of word
    running

    xl2000 purportedly had some problems using the with construct in an
    automation environment. Perhaps the error has reappeared in xl2003.

    Looks like you have created a reference to the Word Object model (make sure
    it is the correct version), so constant definitions shouldn't be a problem.

    --
    Regards,
    Tom Ogilvy



    "Joel Berry" <> wrote in message
    news:...
    > Thanks, Tom.
    >
    > You're right. The line is the "^pBREAK" line. I was testing it again with

    a
    > different text to find. So, the line that is causing the crash is the

    ".Text
    > = ^pBREAK" line.
    >
    > The reason I posted it here is because it works flawlessly in Word 2003.
    > It's when you call it from a Word.Application object from within Excel

    that
    > it crashes. So, it's not necessarily a Word problem. Make sense?
    >
    > "Tom Ogilvy" wrote:
    >
    > > There is no line
    > >
    > > <.Text = "^pDescription">
    > >
    > > regardless,
    > > since all of this is performing actions in word, why not ask in a word

    group
    > > where you may have a higher probability of reaching someone who knows

    about
    > > the word object model.
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > >
    > > "Joel Berry" <> wrote in message
    > > news:...
    > > > I just upgraded to Office Professional 2003 from Office Professional

    XP.
    > > >
    > > > The following code, when executed, completely and irrevocably crashes
    > > > Microsoft Excel 2003 at the line <.Text = "^pDescription">. It worked

    just
    > > > find in Microsoft Excel XP. It even asks to send a report to

    Microsoft.
    > > Every
    > > > time. Easily reproducible. I have updated to all service

    packs/patches,
    > > etc.,
    > > > too.
    > > >
    > > > Also, the line <Selection.Find.Replacement.ClearFormatting> gives a
    > > > "Automation error: the procedure number is out of range" error, which

    it
    > > > didn't do before in Excel 2003.
    > > >
    > > > What the heck happened between the two versions? Now my code has

    > > completely
    > > > blown up!!! Any ideas????? Any help would be greatly appreciated, as

    we
    > > have
    > > > to get this program up and running for production! Thanks!!!
    > > >
    > > > Public Sub Test()
    > > > Dim appWord As Word.Application
    > > >
    > > > Set appWord = New Word.Application
    > > > appWord.Documents.Add
    > > >
    > > > appWord.Selection.Find.ClearFormatting
    > > > appWord.Selection.Find.Replacement.ClearFormatting
    > > > With appWord.Selection.Find
    > > > .Text = "^pBREAK"
    > > > .Replacement.Text = "-----"
    > > > .Forward = True
    > > > .Wrap = wdFindContinue
    > > > .Format = False
    > > > .MatchCase = False
    > > > .MatchWholeWord = False
    > > > .MatchWildcards = False
    > > > .MatchSoundsLike = False
    > > > .MatchAllWordForms = False
    > > > End With
    > > > appwordSelection.Find.Execute Replace:=wdReplaceAll
    > > >
    > > > appWord.ActiveDocument.SaveAs "C:\TEST.DOC"
    > > > appWord.ActiveDocument.Close
    > > > appWord.Quit
    > > >
    > > > Set appWord = Nothing
    > > >
    > > > End Sub
    > > >

    > >
    > >
    > >
     
    Tom Ogilvy, Mar 2, 2006
    #4
  5. Guest

    Guest Guest

    Re: Word 2003 Find/Change Automation from Excel 2003 crashes Excel

    It worked perfectly under Excel XP (2002), but it hasn't worked yet under
    Excel 2003. Yes, there are all kinds of WINWORD.EXEs running in the task
    manager -- one for every time I have run this and it fails (which is every
    time). It runs the code perfectly until it gets to the <.Text=...> line, and
    then it crashes Excel!

    "Tom Ogilvy" wrote:

    > Did it work the first time you ran it? Then develop problems.
    > Look in the task manager and see if you have multiple versions of word
    > running
    >
    > xl2000 purportedly had some problems using the with construct in an
    > automation environment. Perhaps the error has reappeared in xl2003.
    >
    > Looks like you have created a reference to the Word Object model (make sure
    > it is the correct version), so constant definitions shouldn't be a problem.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    >
    > "Joel Berry" <> wrote in message
    > news:...
    > > Thanks, Tom.
    > >
    > > You're right. The line is the "^pBREAK" line. I was testing it again with

    > a
    > > different text to find. So, the line that is causing the crash is the

    > ".Text
    > > = ^pBREAK" line.
    > >
    > > The reason I posted it here is because it works flawlessly in Word 2003.
    > > It's when you call it from a Word.Application object from within Excel

    > that
    > > it crashes. So, it's not necessarily a Word problem. Make sense?
    > >
    > > "Tom Ogilvy" wrote:
    > >
    > > > There is no line
    > > >
    > > > <.Text = "^pDescription">
    > > >
    > > > regardless,
    > > > since all of this is performing actions in word, why not ask in a word

    > group
    > > > where you may have a higher probability of reaching someone who knows

    > about
    > > > the word object model.
    > > >
    > > > --
    > > > Regards,
    > > > Tom Ogilvy
    > > >
    > > >
    > > > "Joel Berry" <> wrote in message
    > > > news:...
    > > > > I just upgraded to Office Professional 2003 from Office Professional

    > XP.
    > > > >
    > > > > The following code, when executed, completely and irrevocably crashes
    > > > > Microsoft Excel 2003 at the line <.Text = "^pDescription">. It worked

    > just
    > > > > find in Microsoft Excel XP. It even asks to send a report to

    > Microsoft.
    > > > Every
    > > > > time. Easily reproducible. I have updated to all service

    > packs/patches,
    > > > etc.,
    > > > > too.
    > > > >
    > > > > Also, the line <Selection.Find.Replacement.ClearFormatting> gives a
    > > > > "Automation error: the procedure number is out of range" error, which

    > it
    > > > > didn't do before in Excel 2003.
    > > > >
    > > > > What the heck happened between the two versions? Now my code has
    > > > completely
    > > > > blown up!!! Any ideas????? Any help would be greatly appreciated, as

    > we
    > > > have
    > > > > to get this program up and running for production! Thanks!!!
    > > > >
    > > > > Public Sub Test()
    > > > > Dim appWord As Word.Application
    > > > >
    > > > > Set appWord = New Word.Application
    > > > > appWord.Documents.Add
    > > > >
    > > > > appWord.Selection.Find.ClearFormatting
    > > > > appWord.Selection.Find.Replacement.ClearFormatting
    > > > > With appWord.Selection.Find
    > > > > .Text = "^pBREAK"
    > > > > .Replacement.Text = "-----"
    > > > > .Forward = True
    > > > > .Wrap = wdFindContinue
    > > > > .Format = False
    > > > > .MatchCase = False
    > > > > .MatchWholeWord = False
    > > > > .MatchWildcards = False
    > > > > .MatchSoundsLike = False
    > > > > .MatchAllWordForms = False
    > > > > End With
    > > > > appwordSelection.Find.Execute Replace:=wdReplaceAll
    > > > >
    > > > > appWord.ActiveDocument.SaveAs "C:\TEST.DOC"
    > > > > appWord.ActiveDocument.Close
    > > > > appWord.Quit
    > > > >
    > > > > Set appWord = Nothing
    > > > >
    > > > > End Sub
    > > > >
    > > >
    > > >
    > > >

    >
    >
    >
     
    Guest, Mar 2, 2006
    #5
  6. Guest

    Tom Ogilvy Guest

    Re: Word 2003 Find/Change Automation from Excel 2003 crashes Excel

    I don't have xl2003 installed here, but running in xl2002 I got an error in

    appWordSelection.Find.Execute Replace:=wdReplaceAll

    for the obvious reason. It did put an instance or word running in the task
    manager. It ran fine after that, but perhaps that might not be the case in
    xl2003. I would fix the code, then close excel. Make sure the task manager
    has no instances of word running, then try again.

    --
    Regards,
    Tom Ogilvy

    "Joel Berry" <> wrote in message
    news:...
    > It worked perfectly under Excel XP (2002), but it hasn't worked yet under
    > Excel 2003. Yes, there are all kinds of WINWORD.EXEs running in the task
    > manager -- one for every time I have run this and it fails (which is every
    > time). It runs the code perfectly until it gets to the <.Text=...> line,

    and
    > then it crashes Excel!
    >
    > "Tom Ogilvy" wrote:
    >
    > > Did it work the first time you ran it? Then develop problems.
    > > Look in the task manager and see if you have multiple versions of word
    > > running
    > >
    > > xl2000 purportedly had some problems using the with construct in an
    > > automation environment. Perhaps the error has reappeared in xl2003.
    > >
    > > Looks like you have created a reference to the Word Object model (make

    sure
    > > it is the correct version), so constant definitions shouldn't be a

    problem.
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > >
    > >
    > > "Joel Berry" <> wrote in message
    > > news:...
    > > > Thanks, Tom.
    > > >
    > > > You're right. The line is the "^pBREAK" line. I was testing it again

    with
    > > a
    > > > different text to find. So, the line that is causing the crash is the

    > > ".Text
    > > > = ^pBREAK" line.
    > > >
    > > > The reason I posted it here is because it works flawlessly in Word

    2003.
    > > > It's when you call it from a Word.Application object from within Excel

    > > that
    > > > it crashes. So, it's not necessarily a Word problem. Make sense?
    > > >
    > > > "Tom Ogilvy" wrote:
    > > >
    > > > > There is no line
    > > > >
    > > > > <.Text = "^pDescription">
    > > > >
    > > > > regardless,
    > > > > since all of this is performing actions in word, why not ask in a

    word
    > > group
    > > > > where you may have a higher probability of reaching someone who

    knows
    > > about
    > > > > the word object model.
    > > > >
    > > > > --
    > > > > Regards,
    > > > > Tom Ogilvy
    > > > >
    > > > >
    > > > > "Joel Berry" <> wrote in message
    > > > > news:...
    > > > > > I just upgraded to Office Professional 2003 from Office

    Professional
    > > XP.
    > > > > >
    > > > > > The following code, when executed, completely and irrevocably

    crashes
    > > > > > Microsoft Excel 2003 at the line <.Text = "^pDescription">. It

    worked
    > > just
    > > > > > find in Microsoft Excel XP. It even asks to send a report to

    > > Microsoft.
    > > > > Every
    > > > > > time. Easily reproducible. I have updated to all service

    > > packs/patches,
    > > > > etc.,
    > > > > > too.
    > > > > >
    > > > > > Also, the line <Selection.Find.Replacement.ClearFormatting> gives

    a
    > > > > > "Automation error: the procedure number is out of range" error,

    which
    > > it
    > > > > > didn't do before in Excel 2003.
    > > > > >
    > > > > > What the heck happened between the two versions? Now my code has
    > > > > completely
    > > > > > blown up!!! Any ideas????? Any help would be greatly appreciated,

    as
    > > we
    > > > > have
    > > > > > to get this program up and running for production! Thanks!!!
    > > > > >
    > > > > > Public Sub Test()
    > > > > > Dim appWord As Word.Application
    > > > > >
    > > > > > Set appWord = New Word.Application
    > > > > > appWord.Documents.Add
    > > > > >
    > > > > > appWord.Selection.Find.ClearFormatting
    > > > > > appWord.Selection.Find.Replacement.ClearFormatting
    > > > > > With appWord.Selection.Find
    > > > > > .Text = "^pBREAK"
    > > > > > .Replacement.Text = "-----"
    > > > > > .Forward = True
    > > > > > .Wrap = wdFindContinue
    > > > > > .Format = False
    > > > > > .MatchCase = False
    > > > > > .MatchWholeWord = False
    > > > > > .MatchWildcards = False
    > > > > > .MatchSoundsLike = False
    > > > > > .MatchAllWordForms = False
    > > > > > End With
    > > > > > appwordSelection.Find.Execute Replace:=wdReplaceAll
    > > > > >
    > > > > > appWord.ActiveDocument.SaveAs "C:\TEST.DOC"
    > > > > > appWord.ActiveDocument.Close
    > > > > > appWord.Quit
    > > > > >
    > > > > > Set appWord = Nothing
    > > > > >
    > > > > > End Sub
    > > > > >
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >
     
    Tom Ogilvy, Mar 2, 2006
    #6
  7. Guest

    Guest Guest

    Re: Word 2003 Find/Change Automation from Excel 2003 crashes Excel

    Thanks, Tom -- the error you got comes from my mistake: there should be a
    period after "appWord" in that line of code -- I went through and added an
    appWord object to specifiy the Selection object, since I was calling it from
    outside of Word. I just missed the period. That's probably why you got the
    error...

    "Tom Ogilvy" wrote:

    > I don't have xl2003 installed here, but running in xl2002 I got an error in
    >
    > appWordSelection.Find.Execute Replace:=wdReplaceAll
    >
    > for the obvious reason. It did put an instance or word running in the task
    > manager. It ran fine after that, but perhaps that might not be the case in
    > xl2003. I would fix the code, then close excel. Make sure the task manager
    > has no instances of word running, then try again.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Joel Berry" <> wrote in message
    > news:...
    > > It worked perfectly under Excel XP (2002), but it hasn't worked yet under
    > > Excel 2003. Yes, there are all kinds of WINWORD.EXEs running in the task
    > > manager -- one for every time I have run this and it fails (which is every
    > > time). It runs the code perfectly until it gets to the <.Text=...> line,

    > and
    > > then it crashes Excel!
    > >
    > > "Tom Ogilvy" wrote:
    > >
    > > > Did it work the first time you ran it? Then develop problems.
    > > > Look in the task manager and see if you have multiple versions of word
    > > > running
    > > >
    > > > xl2000 purportedly had some problems using the with construct in an
    > > > automation environment. Perhaps the error has reappeared in xl2003.
    > > >
    > > > Looks like you have created a reference to the Word Object model (make

    > sure
    > > > it is the correct version), so constant definitions shouldn't be a

    > problem.
    > > >
    > > > --
    > > > Regards,
    > > > Tom Ogilvy
    > > >
    > > >
    > > >
    > > > "Joel Berry" <> wrote in message
    > > > news:...
    > > > > Thanks, Tom.
    > > > >
    > > > > You're right. The line is the "^pBREAK" line. I was testing it again

    > with
    > > > a
    > > > > different text to find. So, the line that is causing the crash is the
    > > > ".Text
    > > > > = ^pBREAK" line.
    > > > >
    > > > > The reason I posted it here is because it works flawlessly in Word

    > 2003.
    > > > > It's when you call it from a Word.Application object from within Excel
    > > > that
    > > > > it crashes. So, it's not necessarily a Word problem. Make sense?
    > > > >
    > > > > "Tom Ogilvy" wrote:
    > > > >
    > > > > > There is no line
    > > > > >
    > > > > > <.Text = "^pDescription">
    > > > > >
    > > > > > regardless,
    > > > > > since all of this is performing actions in word, why not ask in a

    > word
    > > > group
    > > > > > where you may have a higher probability of reaching someone who

    > knows
    > > > about
    > > > > > the word object model.
    > > > > >
    > > > > > --
    > > > > > Regards,
    > > > > > Tom Ogilvy
    > > > > >
    > > > > >
    > > > > > "Joel Berry" <> wrote in message
    > > > > > news:...
    > > > > > > I just upgraded to Office Professional 2003 from Office

    > Professional
    > > > XP.
    > > > > > >
    > > > > > > The following code, when executed, completely and irrevocably

    > crashes
    > > > > > > Microsoft Excel 2003 at the line <.Text = "^pDescription">. It

    > worked
    > > > just
    > > > > > > find in Microsoft Excel XP. It even asks to send a report to
    > > > Microsoft.
    > > > > > Every
    > > > > > > time. Easily reproducible. I have updated to all service
    > > > packs/patches,
    > > > > > etc.,
    > > > > > > too.
    > > > > > >
    > > > > > > Also, the line <Selection.Find.Replacement.ClearFormatting> gives

    > a
    > > > > > > "Automation error: the procedure number is out of range" error,

    > which
    > > > it
    > > > > > > didn't do before in Excel 2003.
    > > > > > >
    > > > > > > What the heck happened between the two versions? Now my code has
    > > > > > completely
    > > > > > > blown up!!! Any ideas????? Any help would be greatly appreciated,

    > as
    > > > we
    > > > > > have
    > > > > > > to get this program up and running for production! Thanks!!!
    > > > > > >
    > > > > > > Public Sub Test()
    > > > > > > Dim appWord As Word.Application
    > > > > > >
    > > > > > > Set appWord = New Word.Application
    > > > > > > appWord.Documents.Add
    > > > > > >
    > > > > > > appWord.Selection.Find.ClearFormatting
    > > > > > > appWord.Selection.Find.Replacement.ClearFormatting
    > > > > > > With appWord.Selection.Find
    > > > > > > .Text = "^pBREAK"
    > > > > > > .Replacement.Text = "-----"
    > > > > > > .Forward = True
    > > > > > > .Wrap = wdFindContinue
    > > > > > > .Format = False
    > > > > > > .MatchCase = False
    > > > > > > .MatchWholeWord = False
    > > > > > > .MatchWildcards = False
    > > > > > > .MatchSoundsLike = False
    > > > > > > .MatchAllWordForms = False
    > > > > > > End With
    > > > > > > appwordSelection.Find.Execute Replace:=wdReplaceAll
    > > > > > >
    > > > > > > appWord.ActiveDocument.SaveAs "C:\TEST.DOC"
    > > > > > > appWord.ActiveDocument.Close
    > > > > > > appWord.Quit
    > > > > > >
    > > > > > > Set appWord = Nothing
    > > > > > >
    > > > > > > End Sub
    > > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > >
    > > >
    > > >

    >
    >
    >
     
    Guest, Mar 2, 2006
    #7
  8. Guest

    Tom Ogilvy Guest

    Re: Word 2003 Find/Change Automation from Excel 2003 crashes Excel

    > for the obvious reason.

    --
    Regards,
    Tom Ogilvy

    "Joel Berry" <> wrote in message
    news:...
    > Thanks, Tom -- the error you got comes from my mistake: there should be a
    > period after "appWord" in that line of code -- I went through and added an
    > appWord object to specifiy the Selection object, since I was calling it

    from
    > outside of Word. I just missed the period. That's probably why you got the
    > error...
    >
    > "Tom Ogilvy" wrote:
    >
    > > I don't have xl2003 installed here, but running in xl2002 I got an error

    in
    > >
    > > appWordSelection.Find.Execute Replace:=wdReplaceAll
    > >
    > > for the obvious reason. It did put an instance or word running in the

    task
    > > manager. It ran fine after that, but perhaps that might not be the case

    in
    > > xl2003. I would fix the code, then close excel. Make sure the task

    manager
    > > has no instances of word running, then try again.
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > > "Joel Berry" <> wrote in message
    > > news:...
    > > > It worked perfectly under Excel XP (2002), but it hasn't worked yet

    under
    > > > Excel 2003. Yes, there are all kinds of WINWORD.EXEs running in the

    task
    > > > manager -- one for every time I have run this and it fails (which is

    every
    > > > time). It runs the code perfectly until it gets to the <.Text=...>

    line,
    > > and
    > > > then it crashes Excel!
    > > >
    > > > "Tom Ogilvy" wrote:
    > > >
    > > > > Did it work the first time you ran it? Then develop problems.
    > > > > Look in the task manager and see if you have multiple versions of

    word
    > > > > running
    > > > >
    > > > > xl2000 purportedly had some problems using the with construct in an
    > > > > automation environment. Perhaps the error has reappeared in xl2003.
    > > > >
    > > > > Looks like you have created a reference to the Word Object model

    (make
    > > sure
    > > > > it is the correct version), so constant definitions shouldn't be a

    > > problem.
    > > > >
    > > > > --
    > > > > Regards,
    > > > > Tom Ogilvy
    > > > >
    > > > >
    > > > >
    > > > > "Joel Berry" <> wrote in message
    > > > > news:...
    > > > > > Thanks, Tom.
    > > > > >
    > > > > > You're right. The line is the "^pBREAK" line. I was testing it

    again
    > > with
    > > > > a
    > > > > > different text to find. So, the line that is causing the crash is

    the
    > > > > ".Text
    > > > > > = ^pBREAK" line.
    > > > > >
    > > > > > The reason I posted it here is because it works flawlessly in Word

    > > 2003.
    > > > > > It's when you call it from a Word.Application object from within

    Excel
    > > > > that
    > > > > > it crashes. So, it's not necessarily a Word problem. Make sense?
    > > > > >
    > > > > > "Tom Ogilvy" wrote:
    > > > > >
    > > > > > > There is no line
    > > > > > >
    > > > > > > <.Text = "^pDescription">
    > > > > > >
    > > > > > > regardless,
    > > > > > > since all of this is performing actions in word, why not ask in

    a
    > > word
    > > > > group
    > > > > > > where you may have a higher probability of reaching someone who

    > > knows
    > > > > about
    > > > > > > the word object model.
    > > > > > >
    > > > > > > --
    > > > > > > Regards,
    > > > > > > Tom Ogilvy
    > > > > > >
    > > > > > >
    > > > > > > "Joel Berry" <> wrote in

    message
    > > > > > > news:...
    > > > > > > > I just upgraded to Office Professional 2003 from Office

    > > Professional
    > > > > XP.
    > > > > > > >
    > > > > > > > The following code, when executed, completely and irrevocably

    > > crashes
    > > > > > > > Microsoft Excel 2003 at the line <.Text = "^pDescription">. It

    > > worked
    > > > > just
    > > > > > > > find in Microsoft Excel XP. It even asks to send a report to
    > > > > Microsoft.
    > > > > > > Every
    > > > > > > > time. Easily reproducible. I have updated to all service
    > > > > packs/patches,
    > > > > > > etc.,
    > > > > > > > too.
    > > > > > > >
    > > > > > > > Also, the line <Selection.Find.Replacement.ClearFormatting>

    gives
    > > a
    > > > > > > > "Automation error: the procedure number is out of range"

    error,
    > > which
    > > > > it
    > > > > > > > didn't do before in Excel 2003.
    > > > > > > >
    > > > > > > > What the heck happened between the two versions? Now my code

    has
    > > > > > > completely
    > > > > > > > blown up!!! Any ideas????? Any help would be greatly

    appreciated,
    > > as
    > > > > we
    > > > > > > have
    > > > > > > > to get this program up and running for production! Thanks!!!
    > > > > > > >
    > > > > > > > Public Sub Test()
    > > > > > > > Dim appWord As Word.Application
    > > > > > > >
    > > > > > > > Set appWord = New Word.Application
    > > > > > > > appWord.Documents.Add
    > > > > > > >
    > > > > > > > appWord.Selection.Find.ClearFormatting
    > > > > > > > appWord.Selection.Find.Replacement.ClearFormatting
    > > > > > > > With appWord.Selection.Find
    > > > > > > > .Text = "^pBREAK"
    > > > > > > > .Replacement.Text = "-----"
    > > > > > > > .Forward = True
    > > > > > > > .Wrap = wdFindContinue
    > > > > > > > .Format = False
    > > > > > > > .MatchCase = False
    > > > > > > > .MatchWholeWord = False
    > > > > > > > .MatchWildcards = False
    > > > > > > > .MatchSoundsLike = False
    > > > > > > > .MatchAllWordForms = False
    > > > > > > > End With
    > > > > > > > appwordSelection.Find.Execute Replace:=wdReplaceAll
    > > > > > > >
    > > > > > > > appWord.ActiveDocument.SaveAs "C:\TEST.DOC"
    > > > > > > > appWord.ActiveDocument.Close
    > > > > > > > appWord.Quit
    > > > > > > >
    > > > > > > > Set appWord = Nothing
    > > > > > > >
    > > > > > > > End Sub
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > > >
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >
     
    Tom Ogilvy, Mar 3, 2006
    #8
  9. Re: Word 2003 Find/Change Automation from Excel 2003 crashes Excel

    Hello
    I think I have the same problem but I didnt really understand the
    solution :-((. Can you please give me a hint what to change in the code
    to prevent Excel from crashing?
    Thank you very much!
    Hein


    Sub test()
    Dim wrdApp As Word.Application
    Dim PfadMod2 As String
    Set wrdApp = New Word.Application

    PfadMod2 = "H:\temp9\GesprächAnfang
    März\PSS-Burghaun-Auestr-22-EifertLo"

    wrdApp.ChangeFileOpenDirectory _
    PfadMod2 '

    wrdApp.Documents.Open Filename:="LV.dot",
    ConfirmConversions:=False, _
    ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
    PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
    WritePasswordTemplate:="", Format:=wdOpenFormatAuto
    wrdApp.Visible = True
    wrdApp.ActiveWindow.ActivePane.View.SeekView =
    wdSeekCurrentPageHeader
    wrdApp.ActiveWindow.ActivePane.View.NextHeaderFooter
    wrdApp.ActiveWindow.ActivePane.View.NextHeaderFooter
    wrdApp.Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="1"

    wrdApp.Selection.Find.ClearFormatting
    With wrdApp.Selection.Find
    .Text = "#R#"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    wrdApp.Selection.Find.Execute

    End Sub
     
    Hein Heinrichsen, Mar 6, 2006
    #9
  10. Re: Word 2003 Find/Change Automation from Excel 2003 crashes Excel

    I got it:

    http://support.microsoft.com/kb/292744/EN-US/


    Hein Heinrichsen wrote:

    > Hello
    > I think I have the same problem but I didnt really understand the
    > solution :-((. Can you please give me a hint what to change in the
    > code to prevent Excel from crashing?
    > Thank you very much!
    > Hein
    >
    >
    > Sub test()
    > Dim wrdApp As Word.Application
    > Dim PfadMod2 As String
    > Set wrdApp = New Word.Application
    > PfadMod2 = "H:\temp9\GesprächAnfang
    > März\PSS-Burghaun-Auestr-22-EifertLo"
    > wrdApp.ChangeFileOpenDirectory _
    > PfadMod2 '
    > wrdApp.Documents.Open Filename:="LV.dot",
    > ConfirmConversions:=False, _
    > ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
    > PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
    > WritePasswordTemplate:="", Format:=wdOpenFormatAuto
    > wrdApp.Visible = True
    > wrdApp.ActiveWindow.ActivePane.View.SeekView =
    > wdSeekCurrentPageHeader
    > wrdApp.ActiveWindow.ActivePane.View.NextHeaderFooter
    > wrdApp.ActiveWindow.ActivePane.View.NextHeaderFooter
    > wrdApp.Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext,
    > Name:="1"
    > wrdApp.Selection.Find.ClearFormatting
    > With wrdApp.Selection.Find
    > .Text = "#R#"
    > .Replacement.Text = ""
    > .Forward = True
    > .Wrap = wdFindContinue
    > .Format = False
    > .MatchCase = False
    > .MatchWholeWord = False
    > .MatchWildcards = False
    > .MatchSoundsLike = False
    > .MatchAllWordForms = False
    > End With
    > wrdApp.Selection.Find.Execute
    >
    > End Sub
     
    Hein Heinrichsen, Mar 6, 2006
    #10
    1. Advertisements

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. scorpion53061

    Excel Automation Find/Replace Excel 2000 and 2003

    scorpion53061, Jan 30, 2004, in forum: Microsoft Excel Programming
    Replies:
    0
    Views:
    438
    scorpion53061
    Jan 30, 2004
  2. Grotifant

    Find x number of lowest values from a 200 x 200 matrix

    Grotifant, Feb 23, 2005, in forum: Microsoft Excel Programming
    Replies:
    3
    Views:
    278
    Bernie Deitrick
    Feb 24, 2005
  3. Christian Friedrich

    Visible automated Excel: automation crashes if user selects cells, protection?

    Christian Friedrich, Nov 1, 2006, in forum: Microsoft Excel Programming
    Replies:
    1
    Views:
    164
    NickHK
    Nov 3, 2006
  4. Mike Lavender

    Excel 200 Automation and IIS7

    Mike Lavender, May 5, 2007, in forum: Microsoft Excel Programming
    Replies:
    0
    Views:
    451
    Mike Lavender
    May 5, 2007
  5. apondu
    Replies:
    0
    Views:
    276
    apondu
    Jul 19, 2007
Loading...

Share This Page