use range object

F

FotoArt

hello everyone

i have here a piece of code provided by doug.
i wan to put he whole content of the document in a range object and do the
search.
i hope by doing that i leave the selection intact.

any help is appreciated
thanx
ahmed
 
H

Helmut Weber

Hi Ahmed,

Dim rDcm as range
set rDcm = activedocument.range

What are you trying to achieve?

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
T

Tony Jollans

A bit more info would be helpful, but ActiveDocument.Range will give you
the Range you want, and it has a Find object you can use.
 
D

Doug Robbins - Word MVP

The following modification of the code that I provided will return the
selection to its initial location.

Dim Seconds As Long
Dim srange as Range
Set srange = Selection.Range
Seconds = 0
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(Findtext:="[0-9]{2}:[0-9]{2}:[0-9]{2}", Forward:=True,
_
MatchWildcards:=True, Wrap:=wdFindStop, MatchCase:=True) = True
Seconds = Seconds + Val(Left(Selection, 2)) * 3600 +
Val(Mid(Selection, 4, 2)) * 60 + Val(Right(Selection, 2))
Selection.Collapse wdCollapseEnd
Loop
End With
With ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range
.Text = "Total Time = " & Format(Int(Seconds / 3600), "00") & ":" &
Format(Int((Seconds Mod 3600) / 60), "00") & ":" & Format((Seconds Mod 60),
"00")
.ParagraphFormat.Alignment = wdAlignParagraphRight
End With
srange.Select


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top