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 / October 2006

Tip: Looking for answers? Try searching our database.

Range Properties Limitation?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
George Lee - 17 Oct 2006 19:26 GMT
Is there a limitation to using Range's Start and End properties directly? In
the help files, the following works properly:
    Set rngDoc = ActiveDocument.Range(Start:=0, End:=10)
as does
    ActiveDocument.Range(Start:=0, End:=10).Bold = True

But using this in my code, I always get "Wrong number of arguments or
invalid property assignment" when using:
    myString = Selection.Range(Start:=100, End:=150).Text
or
    myString = whichDocument.Tables(1).Range(Start:=100, End:=150).Text
Doug Robbins - Word MVP - 17 Oct 2006 20:49 GMT
I would use

Dim myrange As Range
Set myrange = Selection.Range
myrange.Start = myrange.Start + 100
myrange.End = myrange.Start + 50
myrange.Bold = True

the embolden the 100th thru the 150th characters in the selection.

Signature

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

> Is there a limitation to using Range's Start and End properties directly?
> In
[quoted text clipped - 8 lines]
> or
> myString = whichDocument.Tables(1).Range(Start:=100, End:=150).Text
George Lee - 17 Oct 2006 21:04 GMT
Thanks. That's what I'm currently doing.

The code appears inside a Find.Execute function, so to make it work, I have
to save the Start and End separately, change the range and get the text then
reset the range. Since I'm not actually changing anything, I was hoping I
could just declare the range I want without resetting anything.

> I would use
>
[quoted text clipped - 18 lines]
> > or
> > myString = whichDocument.Tables(1).Range(Start:=100, End:=150).Text
Tony Jollans - 17 Oct 2006 22:36 GMT
The, rather confusing, difference is because Range is a Method of a Document
and takes parameters, and a Property of the Selection which doesn't..

One way to do what you want would be something like this ...

With Selection
   .document.range(.start+100, .start+150).bold=true
End With

--
Enjoy,
Tony

> Is there a limitation to using Range's Start and End properties directly? In
> the help files, the following works properly:
[quoted text clipped - 7 lines]
> or
> myString = whichDocument.Tables(1).Range(Start:=100, End:=150).Text

Rate this thread:






 
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.