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 / September 2005

Tip: Looking for answers? Try searching our database.

How to make a range/selection out of inserted file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gary Hillerson - 14 Sep 2005 20:27 GMT
I'm trying to figure out something that's pretty easy, but I'm semi
brain dead at this point and can't see how:

I have a function that works fine and inserts a new page at the end of
the current section, then adds a couple paragraphs, something like
this:

Function DoPageInsert(headingStyleName, theHeadingText) as Range
   With Selection
       .EndOf unit:=wdSection
       .Collapse Direction:=wdCollapseEnd
       .InsertBreak Type:=wdSectionBreakNextPage
       .InsertParagraph
        .Style = headingStyleName
        .InsertBefore theHeadingText
         .Collapse Direction:=wdCollapseEnd
      Set DoPageInsert = Selection.Range
End With

I then call that function (which works fine) to create a new page, and
then insert the contents of a file into that page:

    Set rng = DoPageInsert("TestStyle", "MyText")
    rng.Select
      with Selection
        .Collapse Direction := wdCollapseStart
        .InsertFile FileName;= "myFileName", _
              ConfirmConversions:=False, Link:=False, _
             Attachment:=False
        ....
    end With

THE PROBLEM: at this point, I want to search through the page, i.e.
through the content I just inserted from the file.I don't know how to
get a range or selection that represents just that text. I can jump to
the top of my page, but I don't know how to create a range that
encompasses what i just inserted.

Any help?

thanks in advance,
  gary hillerson
Gary Hillerson - 14 Sep 2005 23:16 GMT
Nevermind....I figured it out: I was able to select the new section's
range

>I'm trying to figure out something that's pretty easy, but I'm semi
>brain dead at this point and can't see how:
[quoted text clipped - 38 lines]
>thanks in advance,
>   gary hillerson
 
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.