PC Review


Reply
Thread Tools Rate Thread

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

 
 
=?Utf-8?B?Sm9lbCBCZXJyeQ==?=
Guest
Posts: n/a
 
      2nd Mar 2006
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

 
Reply With Quote
 
 
 
 
Tom Ogilvy
Guest
Posts: n/a
 
      2nd Mar 2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lbCBCZXJyeQ==?=
Guest
Posts: n/a
 
      2nd Mar 2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >

>
>
>

 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      2nd Mar 2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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
> > >

> >
> >
> >



 
Reply With Quote
 
=?Utf-8?B?Sm9lbCBCZXJyeQ==?=
Guest
Posts: n/a
 
      2nd Mar 2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed)...
> > > > 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
> > > >
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      2nd Mar 2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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" <(E-Mail Removed)> wrote in message
> > > > news:(E-Mail Removed)...
> > > > > 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
> > > > >
> > > >
> > > >
> > > >

> >
> >
> >



 
Reply With Quote
 
=?Utf-8?B?Sm9lbCBCZXJyeQ==?=
Guest
Posts: n/a
 
      2nd Mar 2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed)...
> > > > 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" <(E-Mail Removed)> wrote in message
> > > > > news:(E-Mail Removed)...
> > > > > > 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
> > > > > >
> > > > >
> > > > >
> > > > >
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      3rd Mar 2006
> for the obvious reason.

--
Regards,
Tom Ogilvy

"Joel Berry" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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" <(E-Mail Removed)> wrote in message
> > > > news:(E-Mail Removed)...
> > > > > 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" <(E-Mail Removed)> wrote in

message
> > > > > > news:(E-Mail Removed)...
> > > > > > > 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
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > >
> > > >
> > > >

> >
> >
> >



 
Reply With Quote
 
Hein Heinrichsen
Guest
Posts: n/a
 
      6th Mar 2006
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
 
Reply With Quote
 
Hein Heinrichsen
Guest
Posts: n/a
 
      6th Mar 2006
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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
after a ftp put command it just says "200 PORT command successful." and hangs forever. What could be wrong? when i test the ftp server using IE in "passive" mode it works fine. but ftp at command line hangs on "200 PORT comma Daniel Microsoft Windows 2000 Security 7 7th Jun 2014 05:24 AM
A1 = 200:1, B1 is 200 / 1 (200 from A1 - How to exclude :1?) wcooke Microsoft Excel Worksheet Functions 1 5th Mar 2008 05:20 PM
after a ftp put command it just says "200 PORT command successful." and hangs forever. What could be wrong? when i test the ftp server using IE in "passive" mode it works fine. but ftp at command line hangs on "200 PORT comma Daniel Microsoft Windows 2000 1 29th Apr 2006 02:05 AM
Find x number of lowest values from a 200 x 200 matrix Grotifant Microsoft Excel Programming 3 24th Feb 2005 02:13 AM
Convert 200 page Word Doc to 200 separate word docs =?Utf-8?B?SnVsaWU=?= Microsoft Word Document Management 1 14th Jul 2004 11:54 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:56 AM.