View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Andy Andy is offline
external usenet poster
 
Posts: 414
Default Manipulating Word Range object in Excel

I am juggling a couple of Microsoft application objects from within Excel VBA
Add-In.

Basically, I am creating an draft email using an Outlook object and using
Word object as editor (in Outlook) - all with Office 2003.

All working fine on a couple of machines but on one machine (same build as
others) the code is failing during a Find/Replace in the Word Range object.
It is actually causing Excel to crash with a 'Send to Microsoft' memory stack
error.

The code is roughly :-

Dim WdDoc as Word.Document
Dim WdRg as Word.Range
Dim objEmail As Object
Dim objDrafts As Object

Set objOutlook = New Outlook.Application
Set objDrafts = objOutlook.Session.GetDefaultFolder(olFolderDrafts )

Set objEmail = objDrafts.Items.Add
Set wdDoc = objEmail.GetInspector.WordEditor
Set WdRg = WdDoc.Range(2,100) ' assume text fred somewhere in this range

WdRg.Find.Text = "fred"
WdRg.Replacement.Text = "bert"
WdRg.Find.Execute

Any thoughts why the code should fail (big time, taking out Excel) just on
one machine but works OK on the other clone builds? A User option or Add-In
conflict?

Thanks,
Andy.