Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default Manipulating Word Range object in Excel

Hi, Andy. A few thoughts:

(1) Step through the code (F8) while watching your Locals. Is it the
Find/Replace that's not working? Or is it possible you don't have an
object getting set - either WdRg or WdDoc?

(2) Would it be easier all the way around to simply compose your
email in Word outside of Outlook, then open an Outlook object and copy/
paste your email text? This would avoid any "Word as Email Editor"
problems.

(3) Your Find and Replace code doesn't quite look like what is shown
in the Word VBA Help for the Find and Replace objects. I would want
to do something more like:
WdRg.Find.Execute FindText:="fred", ReplaceWith:="bert", _
Replace:=wdReplaceAll

Ed


On Sep 5, 6:02 am, Andy wrote:
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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Manipulating Word Range object in Excel

Thanks Ed - I'll take a look.

(2) Could have used this approach but need to insert some dynamic data from
excel
(3) I'll take another look at the VBA but it works fine every time on my
machine and two others but not on one particular guy's machine which has the
same 2003 build.

Regards,
Andy.

"Ed from AZ" wrote:

Hi, Andy. A few thoughts:

(1) Step through the code (F8) while watching your Locals. Is it the
Find/Replace that's not working? Or is it possible you don't have an
object getting set - either WdRg or WdDoc?

(2) Would it be easier all the way around to simply compose your
email in Word outside of Outlook, then open an Outlook object and copy/
paste your email text? This would avoid any "Word as Email Editor"
problems.

(3) Your Find and Replace code doesn't quite look like what is shown
in the Word VBA Help for the Find and Replace objects. I would want
to do something more like:
WdRg.Find.Execute FindText:="fred", ReplaceWith:="bert", _
Replace:=wdReplaceAll

Ed


On Sep 5, 6:02 am, Andy wrote:
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.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default Manipulating Word Range object in Excel

(3) I'll take another look at the VBA but it works fine every time on my
machine and two others but not on one particular guy's machine which has the
same 2003 build.


I had the same issue with one person in my office. Come to find out,
this person is one who knows computers and is really into setting her
own preferences. We all started with the same image, but preferences
can make a big difference.

I'm not sure, but I think the Word object you're getting is still
subject to the Outlook object, since you're opening the email editor
of an Outlook object. You might be getting some interactions due to
individual preference settings. Escpecially when you try to automate
all this from Excel VBA!!

You might also try to ask about this in the
microsoft.public.outlook.program_vba NG.

Good luck!

Ed

On Sep 5, 9:42 am, Andy wrote:
Thanks Ed - I'll take a look.

(2) Could have used this approach but need to insert some dynamic data from
excel
(3) I'll take another look at the VBA but it works fine every time on my
machine and two others but not on one particular guy's machine which has the
same 2003 build.

Regards,
Andy.



"Ed from AZ" wrote:
Hi, Andy. A few thoughts:


(1) Step through the code (F8) while watching your Locals. Is it the
Find/Replace that's not working? Or is it possible you don't have an
object getting set - either WdRg or WdDoc?


(2) Would it be easier all the way around to simply compose your
email in Word outside of Outlook, then open an Outlook object and copy/
paste your email text? This would avoid any "Word as Email Editor"
problems.


(3) Your Find and Replace code doesn't quite look like what is shown
in the Word VBA Help for the Find and Replace objects. I would want
to do something more like:
WdRg.Find.Execute FindText:="fred", ReplaceWith:="bert", _
Replace:=wdReplaceAll


Ed


On Sep 5, 6:02 am, Andy wrote:
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.- Hide quoted text -


- Show quoted text -



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel object linked to word will not add sums in word Robin Excel Discussion (Misc queries) 0 March 31st 09 11:10 PM
Have problem in Manipulating Workbook Object and make macro shortest as possible Irmann Excel Worksheet Functions 0 February 5th 08 09:32 AM
Range Object CopyPicture Method; Paste to MS Word Marian Excel Programming 0 July 12th 06 04:31 PM
Manipulating MS Word from Excel?? Simon Lloyd[_802_] Excel Programming 5 June 27th 06 07:06 AM
Manipulating embeded exccel in word JD Excel Programming 0 February 9th 05 02:26 PM


All times are GMT +1. The time now is 06:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"