Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Open Word document, modify and Save

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dana - 24 Jan 2006 12:38 GMT
Hi All

Is there any way that I can read from a word document in a word-by-word
manner and do my own checks on each word (like a spelling checker), and
modify some words where necessary then save the document again.

Any help is highly appreciated.

Regards

Dana
Helmut Weber - 24 Jan 2006 13:40 GMT
Hi Dana,

sure.

Dim oWrd As Object
For Each oWrd In ActiveDocument.Range.Words
  ' what now ?
Next

--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
Dana - 24 Jan 2006 15:15 GMT
Thanks

I think that is what I want.

Regards

> Hi Dana,
>
[quoted text clipped - 10 lines]
> "red.sys" & chr(64) & "t-online.de"
> Word 2002, Windows 2000
Greg - 24 Jan 2006 17:58 GMT
Helmut,

I would have probably started with:

Dim oWord as Word.Range

So I will ask the same question that that fellow Fred has asked.  Why
did you use ... As Object?

I would also have clipped that trailing space:
Sub Test()
Dim oWord As Word.Range 'Object
For Each oWord In ActiveDocument.Range.Words
 If oWord.Characters.Last = " " Then
   oWord.MoveEnd wdCharacter, -1
   'Do something like
   MsgBox oWord
   End If
Next
End Sub
Helmut Weber - 25 Jan 2006 08:52 GMT
Hi Greg,

> Why did you use ... As Object?

Because I didn't know better, but I know now.
I was always wondering about:
paragraph and paragraphs
shape and shapes
section and sections
and why there was a _word_-object missing,
when there was a _words_-object.

>I would also have clipped that trailing space

Yes.

The question was a bit too broad for me,
to put much effort into an answer.
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
Greg Maxey - 25 Jan 2006 11:13 GMT
Helmut,

I share your point about it being a broad question.

Cheers.

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Hi Greg,
>
[quoted text clipped - 19 lines]
> "red.sys" & chr(64) & "t-online.de"
> Word 2002, Windows 2000
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.