473,385 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

massive bold :: interop.word

VB.net 2005 express - Office Word 2003
Office 11 library =references

I need to make from VB.net search in Word for these words: "tree", "bus",
"car"...(complete list contains ca. 50 words)
when find founds word "tree", BOLD entire Row (where is that word "tree"),
search next instance of "tree", BOLD entire Row... when find founds word
"bus", BOLD entire Row, search next instance of "bus", BOLD entire Row...

This code works for only one word:

Imports Word = Microsoft.Office.Interop.Word
Private Sub btnBold_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnBold.Click
Dim oWord As New Word.Application
Dim oDoc As Word.Document
Dim path As String = Me.TextBox1.Text
oWord.Visible = True
oDoc = oWord.Documents.Open(path)
Dim intFound As Integer = 0
Dim rng As Word.Range = oDoc.Content
rng.Find.ClearFormatting()
rng.Find.MatchCase = True
rng.Find.MatchWholeWord = True
rng.Find.MatchWildcards = False
rng.Find.MatchSoundsLike = False
rng.Find.MatchAllWordForms = False
rng.Find.Text = "bus"
rng.Find.Execute()
Do While rng.Find.Found = True
rng.Select()
rng.Bookmarks("\Line").Range.Font.Bold = True
intFound += 1
rng.Find.Execute()
Loop
oDoc.SaveAs(path)
oDoc.Close()
oDoc = Nothing
oWord.Quit()
oWord = Nothing
End Sub
-------------------------
-------------------------
This code DONT WORK, but i'm trying :). I tryed couple of variants and no
success.
Any help apriciated

Dim oWord As New Word.Application
Dim oDoc As Word.Document
Dim path As String = Me.TextBox1.Text
oWord.Visible = True
oDoc = oWord.Documents.Open(path)
Dim rDcm As Word.Range = oDoc.Range
With rDcm.Find
..MatchCase = True
..MatchWholeWord = True
..MatchWildcards = False
..MatchSoundsLike = False
..MatchAllWordForms = False
..Execute(FindText:="tree")
..Execute(FindText:="bus")
..Execute(FindText:="car")
'etc... (other words)
While .Execute
rDcm.Select()
rDcm.Bookmarks("\Line").Range.Font.Bold = True
End While
End With
oDoc.SaveAs(path)
oDoc.Close()
oDoc = Nothing
oWord.Quit()
oWord = Nothing
End Sub
Oct 6 '06 #1
0 1205

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Carlis | last post by:
I want to make a program that, when you have the mouse on a word, that word is bold... and when you don't have the mouse on that word, the word is not bold. Excuse me for my poor English :-( But...
6
by: Ronny sigo | last post by:
Hello all, I have made a form with a lot of entryfields and one button which, when clicked on, transforms all of the entryfields values into a MS Word document. All the formatting is done...
0
by: bracoute | last post by:
Hello ppl... 1) i've finally got my automation launched correctly.. but this time i wanna know how to close my winword.exe process which seems to remain in memory despite closing the app......
2
by: Steve | last post by:
I'm using Visual Studio .NET (not 2003), and am developing a class that works with Word theough the Office PIAs (Interop). I can open word and do things with it programatically, but I can't close...
2
by: William LaMartin | last post by:
I have created a program that allows for the automation of things in Word documents, like changing the values of DocVariables and the links to Excel Sheets. I did it using interoperoperatability,...
3
by: Dustin van de Sande | last post by:
I'm developing a ASP.NET 2.0 web application which exports and imports Word documents. The functionality is implemented in a DLL project which is referenced by the web application. In the DLL...
7
by: R Reyes | last post by:
Can someone please explain to me why I can't get the MS Word Interop assembly to work in my VS2005 project? I'm trying to manipulate MS Word from my Web Form application and I can't get passed...
0
by: R Reyes | last post by:
ISSUE (reposted) =========================== Can someone please explain to me why I can't get the MS Word Interop assembly to work in my VS2005 project? For many people, they say they add the...
1
by: R Reyes | last post by:
ISSUE (reposted) =========================== Can someone please explain to me why I can't get the MS Word Interop assembly to work in my VS2005 project? For many people, they say they add the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.