Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #10  
Old 08-08-2021, 08:44 PM
gmayor's Avatar
gmayor gmayor is offline Help with bookmarks in word. Windows 10 Help with bookmarks in word. Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The 'Fill' macro will write the values to the document.e.g. from your document
Code:
Private Sub CommandButton2_Click()        'BOTON Limpiar'
Dim i As Long
Dim strNombre As String
    For i = 1 To ActiveDocument.Bookmarks.Count
        strNombre = ActiveDocument.Bookmarks(i).Name
        Select Case strNombre
            Case Is = "via"
                Rellenar strNombre, cbovia.Value
            Case Is = "kilometro"
                Rellenar strNombre, txtpk.Text
            Case Is = "partido"
                Rellenar strNombre, "partido value"
            Case Is = "termino"
                Rellenar strNombre, "termino value"
        End Select
    Next i
lbl_Exit:
    Exit Sub
End Sub
Note that you cannot fill a bookmark with nothing.

Or if you follow my suggestion and replace the bookmarks with content controls (Insert Content Control Add-In will do that) then
Code:
Private Sub CommandButton2_Click()        'BOTON Limpiar'
Dim oCC As ContentControl
    For Each oCC In ActiveDocument.ContentControls
        Select Case oCC.Title
            Case Is = "via"
                oCC.rage.Text = cbovia.Value
            Case Is = "kilometro"
                oCC.Range.Text = txtpk.Text
            Case Is = "partido"
                oCC.Range.Text = "partido value"
            Case Is = "termino"
                oCC.Range.Text = "termino value"
        End Select
    Next oCC
lbl_Exit:
    Set oCC = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving a word doc as a pdf with bookmarks MimiCush Word 10 03-26-2018 01:51 PM
Help with bookmarks in word. Deleting only all bookmarks contents not the bookmarks adilprodigy Word VBA 1 10-11-2017 01:31 PM
Help with bookmarks in word. Form updating Bookmarks - writes to the bookmarks multiple times PeterPlys Word VBA 13 01-14-2015 06:41 AM
Help with bookmarks in word. selecting ms word bookmarks using vba dnc Word VBA 4 05-10-2013 04:58 PM
word 2007 bookmarks Dawn Word 0 07-14-2009 01:00 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:15 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft