Results 1 to 12 of 12
  1. #1
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Talking

    I have a Userform with textboxes that populate bookmarks on main document. what I have been trying to do is use the bookmarks to link to other pages. I cant seem to get it to work. I tried copy special paste, no luck and I tried adding another bookmark to see if that would work but it seem to remove bookmark from last location and relocate in new location.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    If you want to refer to the text of a bookmark, you can insert a cross reference to the bookmark. The result will be a REF field that acts as a hyperlink.

    Cross references can be created from the Links section of the Insert tab of the ribbon, and you can create REF fields in VBA if desired.

  3. #3
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='793809' date='17-Sep-2009 17:00']If you want to refer to the text of a bookmark, you can insert a cross reference to the bookmark. The result will be a REF field that acts as a hyperlink.

    Cross references can be created from the Links section of the Insert tab of the ribbon, and you can create REF fields in VBA if desired.[/quote]
    Hi HansV
    Thank you i shall give it a try

  4. #4
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='793809' date='17-Sep-2009 17:00']If you want to refer to the text of a bookmark, you can insert a cross reference to the bookmark. The result will be a REF field that acts as a hyperlink.

    Cross references can be created from the Links section of the Insert tab of the ribbon, and you can create REF fields in VBA if desired.[/quote]
    I have another question in regards to bookmarks. Is it possible use text formfields between bookmarks. I tried to manually inserted them in with a bookmark name , but it seems to lose the bookmarks when refreshed with data. Here's the code I am using at the moment. Eventually I want to add 20 bookmarks from userform. Do I have to use code to enter a new formfield ?

    Code:
    Private Sub CommandButton1_Click()
    Dim oRng As Word.Range
    Dim oBM As Bookmarks
    Set oBM = ActiveDocument.Bookmarks
    Set oRng = oBM("Name").Range
    oRng.Text = Me.TextBox1.Text
    oBM.Add "Name", oRng
    Set oRng = oBM("Address").Range
    oRng.Text = Me.TextBox2.Text
    oBM.Add "Address", oRng
    Set oRng = oBM("City").Range
    oRng.Text = Me.TextBox3.Text
    oBM.Add "City", oRng
    Unload Me
    End Sub

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    A form field automatically has a bookmark associated with it. If you double-click a form field (while the document is unprotected), you can view/change its bookmark name.
    You can set the value of the form field as follows:

    ActiveDocument.FormFields("LastName").Result = Me.txtLastName

    (assuming that you run the code from the userform and that the userform contains a text box named txtLastName)

  6. #6
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='793888' date='18-Sep-2009 07:36']A form field automatically has a bookmark associated with it. If you double-click a form field (while the document is unprotected), you can view/change its bookmark name.
    You can set the value of the form field as follows:

    ActiveDocument.FormFields("LastName").Result = Me.txtLastName

    (assuming that you run the code from the userform and that the userform contains a text box named txtLastName)[/quote]
    Hi HansV
    Thank you, sound easy enough, cool

  7. #7
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    [quote name='ababenchrist' post='793885' date='19-Sep-2009 00:29']I have another question in regards to bookmarks. Is it possible use text formfields between bookmarks. I tried to manually inserted them in with a bookmark name , but it seems to lose the bookmarks when refreshed with data. Here's the code I am using at the moment. Eventually I want to add 20 bookmarks from userform. Do I have to use code to enter a new formfield ?[/quote]
    Hi Gary,

    Your use of formfields seems illogical. If they're replicating data from:
    . another formfield, you don't need a macro. All you need to do is to make the formfield a calulating one, pointing to the paren't bookmark name, and set the parent's properties to 'calculate on exit'. Better yet, you can do away with the child formfield and simply have an ordinary cross-reference; or
    . a userform, you can do all you need with a simple bookmark in the document.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  8. #8
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='macropod' post='794014' date='19-Sep-2009 04:15']Hi Gary,

    Your use of formfields seems illogical. If they're replicating data from:
    . another formfield, you don't need a macro. All you need to do is to make the formfield a calulating one, pointing to the paren't bookmark name, and set the parent's properties to 'calculate on exit'. Better yet, you can do away with the child formfield and simply have an ordinary cross-reference; or
    . a userform, you can do all you need with a simple bookmark in the document.[/quote]
    Hi Macropod
    Thank you
    I was at first using a Userform and bookmarks in my document, using the code previously mentioned and it worked great, but from there I was having a problem trying to use those bookmarks as links to other pages, every time I go to set up another bookmark using the same name it would remove the old bookmark and relocate in my new location. I also tried Cross-reference/bookmark/bookmark text/Name (name of my bookmark) it didnít seem to update or refresh with newly entered data. Iím sure I missing something. any thought greatly appreciated

  9. #9
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Please disregard my last request. I found my error in my bookmark that was not allowing me to copy/Special Paste/linked formatted text to other pages.
    Thank you for all your assistance

  10. #10
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    [quote name='ababenchrist' post='794054' date='20-Sep-2009 01:38']Hi Macropod
    Thank you
    I was at first using a Userform and bookmarks in my document, using the code previously mentioned and it worked great, but from there I was having a problem trying to use those bookmarks as links to other pages, every time I go to set up another bookmark using the same name it would remove the old bookmark and relocate in my new location. I also tried Cross-reference/bookmark/bookmark text/Name (name of my bookmark) it didnít seem to update or refresh with newly entered data. Iím sure I missing something. any thought greatly appreciated[/quote]
    Hi Gary,

    A bookmark can only exist in one place in a document. As a corollary of this, every bookmark name must be unque.

    If you bookmark something, you can cross-reference it via REF fields.

    If you change a bookmark's contents, you need to update the fields. There are various ways to do this, the simplest (for fields in the body of the document) being:
    ActiveDocument.Fields.Update
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  11. #11
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='macropod' post='794211' date='20-Sep-2009 23:01']Hi Gary,

    A bookmark can only exist in one place in a document. As a corollary of this, every bookmark name must be unque.

    If you bookmark something, you can cross-reference it via REF fields.

    If you change a bookmark's contents, you need to update the fields. There are various ways to do this, the simplest (for fields in the body of the document) being:
    ActiveDocument.Fields.Update[/quote]
    Hi macropod
    Very cool thank you
    Also I hope I got this right ? Because I also wanted to protect the bookmarks from accidently getting deleted on the main document. So I applied read only protection. I then added this code to existing code to help protect.
    Code:
    ActiveDocument.Unprotect "password"
    At the beginning of the code so the bookmarks could refresh and
    Code:
    ActiveDocument.Protect wdAllowOnlyReading, NoReset:=True, Password:="password"
    At the end to re-protect. Is this method OK or will it cause me problems down the road. It appears to work Ok, it seems to refresh just fine and reapplied protection.

  12. #12
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    [quote name='ababenchrist' post='794270' date='22-Sep-2009 00:27']Hi macropod
    Very cool thank you
    Also I hope I got this right ? Because I also wanted to protect the bookmarks from accidently getting deleted on the main document. So I applied read only protection. I then added this code to existing code to help protect.
    ...
    Is this method OK or will it cause me problems down the road. It appears to work Ok, it seems to refresh just fine and reapplied protection.[/quote]
    Hi Gary,

    That should be OK.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •