VB and MS Word document bookmarks


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: VB and MS Word document bookmarks

Hybrid View

  1. #1
    Andrew Payne Guest

    VB and MS Word document bookmarks


    Hello Dan:

    I am writing an application that queries a database and pulls up a variant
    array of records.

    The records (parts of them) are then placed into predefined bookmarks in
    an MS Word document.

    The number of records returned can be anywhere from 0 to 30 or more, but
    I have only a constant number of bookmarks.

    I could define a huge number of bookmarks to cover myself, but is there a
    way you know of to dynamically create bookmarks in the Word doc depending
    on how many records are returned?

    Thanks,
    Andy
    Share on Google+

  2. #2
    Dan Appleman Guest

    Re: VB and MS Word document bookmarks

    Sorry, that's way out of my area of expertise. I haven't done VBA word coding
    in ages.

    Best of luck.

    Dan


    Andrew Payne wrote:

    > Hello Dan:
    >
    > I am writing an application that queries a database and pulls up a variant
    > array of records.
    >
    > The records (parts of them) are then placed into predefined bookmarks in
    > an MS Word document.
    >
    > The number of records returned can be anywhere from 0 to 30 or more, but
    > I have only a constant number of bookmarks.
    >
    > I could define a huge number of bookmarks to cover myself, but is there a
    > way you know of to dynamically create bookmarks in the Word doc depending
    > on how many records are returned?
    >
    > Thanks,
    > Andy


    Share on Google+

  3. #3
    Tom Eubank Guest

    Re: VB and MS Word document bookmarks


    Andrew,

    To add a bookmark, you can use either of the following statements:

    dim oBmk as Word.Bookmark
    dim oRng1 as Word.Range, oRng2 as Word.Range

    set oBmk = oRng1.Bookmarks.Add("bmkNew")
    set oBmk = oRng1.Bookmarks.Add("bmkNew", oRng2)

    Both statements add named "bmkNew". Either range can be collapsed. The
    first statement above bookmarks the range identified by oRng1. The second
    statment bookmarks the range identifed by oRng2, and oRng1 can refer to any
    valid range within the document.

    Regards,
    Tom.

    "Andrew Payne" <schatze@peconic.net> wrote:
    >
    >Hello Dan:
    >
    >I am writing an application that queries a database and pulls up a variant
    >array of records.
    >
    >The records (parts of them) are then placed into predefined bookmarks in
    >an MS Word document.
    >
    >The number of records returned can be anywhere from 0 to 30 or more, but
    >I have only a constant number of bookmarks.
    >
    >I could define a huge number of bookmarks to cover myself, but is there

    a
    >way you know of to dynamically create bookmarks in the Word doc depending
    >on how many records are returned?
    >
    >Thanks,
    >Andy


    Share on Google+

  4. #4
    Andrew Payne Guest

    Re: VB and MS Word document bookmarks


    Thank you, Tom
    Andy

    "Tom Eubank" <tom@afcon.com> wrote:
    >
    >Andrew,
    >
    >To add a bookmark, you can use either of the following statements:
    >
    > dim oBmk as Word.Bookmark
    > dim oRng1 as Word.Range, oRng2 as Word.Range
    >
    > set oBmk = oRng1.Bookmarks.Add("bmkNew")
    > set oBmk = oRng1.Bookmarks.Add("bmkNew", oRng2)
    >
    >Both statements add named "bmkNew". Either range can be collapsed. The
    >first statement above bookmarks the range identified by oRng1. The second
    >statment bookmarks the range identifed by oRng2, and oRng1 can refer to

    any
    >valid range within the document.
    >
    >Regards,
    >Tom.
    >
    >"Andrew Payne" <schatze@peconic.net> wrote:
    >>
    >>Hello Dan:
    >>
    >>I am writing an application that queries a database and pulls up a variant
    >>array of records.
    >>
    >>The records (parts of them) are then placed into predefined bookmarks in
    >>an MS Word document.
    >>
    >>The number of records returned can be anywhere from 0 to 30 or more, but
    >>I have only a constant number of bookmarks.
    >>
    >>I could define a huge number of bookmarks to cover myself, but is there

    >a
    >>way you know of to dynamically create bookmarks in the Word doc depending
    >>on how many records are returned?
    >>
    >>Thanks,
    >>Andy

    >


    Share on Google+

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center