Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 150
Default Problem with running sub from Excel

Hi,

When I run the following sub from Word, it highlights all the instance
of the input string. However, when word is invoked from excel, a word
document opened and the sub is called, the word "find" is highlighted
and "Argument not optional" error appears.

Sub HighlightWord()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
rspFind = InputBox("Input the string for highlighting")
With rDcm.Find
.Text = rspFind
While .Execute
rDcm.HighlightColorIndex = wdYellow
Wend
End With

End Sub

Please help. Thanks in Advance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Problem with running sub from Excel

You should be having the Application object and the Document object for MS
Word; and try this.

wrdApp.Options.DefaultHighlightColorIndex = wdYellow
With wrdDoc.Range.Find
.Text = strSearchString
.Replacement.Text = strSearchString
.Replacement.Highlight = True
.MatchCase = False
.MatchWholeWord = False
.Execute Replace:=wdReplaceAll
End With

I have modified the code around find and highlight..and posted..Please check
and feedback..

If this post helps click Yes
---------------
Jacob Skaria


"Raj" wrote:

Hi,

When I run the following sub from Word, it highlights all the instance
of the input string. However, when word is invoked from excel, a word
document opened and the sub is called, the word "find" is highlighted
and "Argument not optional" error appears.

Sub HighlightWord()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
rspFind = InputBox("Input the string for highlighting")
With rDcm.Find
.Text = rspFind
While .Execute
rDcm.HighlightColorIndex = wdYellow
Wend
End With

End Sub

Please help. Thanks in Advance.


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
Running a Word macro from Excel problem PaulC Excel Programming 2 April 22nd 06 09:54 AM
Problem running basic SQL in excel... Rone[_2_] Excel Programming 2 March 15th 06 10:11 PM
Problem Running Code in Excel 2003 Mark Excel Programming 1 June 17th 05 12:45 AM
Strange problem running Word from Excel Robin Excel Programming 5 May 3rd 05 10:22 PM
Problem running macros in Office/Excel 97 Rich J Excel Programming 1 January 29th 04 06:16 PM


All times are GMT +1. The time now is 08:22 AM.

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

About Us

"It's about Microsoft Excel"