I read your last post about it putting text beside instead of updating the
bookmark.
I appreciate your help alot, but I am not really understanding the
code(nothing new). But if I want to update the bookmark with the appropriate
text how would I load this do i need to change the reference in the below sub
to anything
The bookmark is "TextSleeve" and the text to insert is "Packer Setting"
would these be entered below where you show BmkNm and NewTxt.
Sorry for the stupidity
Sub UpdateBookmark (BmkNm as string, NewTxt as string)
Dim BmkRng as Range
With ActiveDocument
If.Bookmarks.Exists(BmkNm) Then
Set BmkRng =.Bookmarks(BmkNm).Range
BmkRng.Text = NewTxt
.Bookmarks.Add BmkNm, BmkRng
End if
End With
Set BmkRng = Nothing
End Sub
which you can call from your command buttons like:
Private Sub CommandButton1_Click()
If cboSleeve > "0" Then
Call UpdateBookmark("TextSleeve", "Packer Setting")
End If
End Sub
durmalbs said:
Here is an example of how the bookmark is populated by the command button
from info entered in Combo Box "Sleeve". The bookmark is named "TextSleeve",
is this not correct?
Private Sub CommandButton1_Click()
If cboSleeve > "0" Then
ActiveDocument.Bookmarks("TextSleeve").Select
Selection.TypeText Text:="Packer Setting"
End If
End Sub
:
Hi durmalbs,
The problem is that whatever your code does, it doesn't populate the bookmarks. As requested, though, the macro deletes the
paragraphs containing empty bookmarks. You have two choices:
1. populate the bookmarks correctly; or
2. modify the macro to delete empty paragrahs containing bookmarks.
--
Cheers
macropod
[Microsoft MVP - Word]
This deletes the bookmarks,but it does all of them. When I hit my command
button it inserts the text into the appropriate bookmark, then there are some
bookmarks left I need to be able to delete those left. When I insert this
then pick my combo box choices the hit my command button to run it adds the
text to the appropriate bookmark, but when I then run this Sub it removes the
bookmarks where the text was inserted along with the blanks.
Any suggestions?
:
Hi durmalbs,
Try:
Sub KillEmptyBkMrkParas()
Dim oBkMk As Bookmark, bBkState As Boolean
With ActiveDocument
bBkState = .Bookmarks.ShowHidden
.Bookmarks.ShowHidden = False
For Each oBkMk In .Bookmarks
If .Bookmarks(oBkMk).Empty = True Then oBkMk.Range.Paragraphs(1).Range.Delete
Next
.Bookmarks.ShowHidden = bBkState
End With
End Sub
Note: I've taken your reference to 'blank bookmarks' to mean they're empty.
--
Cheers
macropod
[Microsoft MVP - Word]
I have a document that once I run the macro to insert text from combo box
choices it still has some blank bookmarks that I would like to have a macro
to delete the bookmarks and the line that was marked ( hope this is not
confusing).
so the document looks like this,
3.42 run packer
3.43 (Bookmark "TextP1")
3.44 Set packer
So I need the macro to delete the whole line 3.43 and move 3.44 up.
Any help would be appreciated I am very new to macros so be gentle if
possible.
.
.