![]() |
|
#1
|
|||
|
|||
|
I need code to find and replace a named table with boilerplate text, launched by icons on the QAT. One icon should replace a table named Prior with "There were no prior audit issues during this engagement." (without the quotation marks) and the other icon launching code to replace a table named Reg with "There were no regulatory issues during this engagement." I also need the text to have Body Text style. Can anyone help me with this? Last edited by kevinbradley57; 08-29-2017 at 02:24 PM. Reason: Corrected title |
|
#2
|
||||
|
||||
|
It's not clear from your post how you're naming the table. That said, what you want is easily done if you simply bookmark the tables concerned, using code like:
Code:
Sub Prior()
Call UpdateBookmark("Prior", "There were no prior audit issues during this engagement." & vbCr)
End Sub
Sub Reg()
Call UpdateBookmark("Reg", "There were no regulatory issues during this engagement." & vbCr)
End Sub
Sub UpdateBookmark(StrBkMk As String, StrTxt As String)
Application.ScreenUpdating = False
Dim BkMkRng As Range
With ActiveDocument
If .Bookmarks.Exists(StrBkMk) Then
Set BkMkRng = .Bookmarks(StrBkMk).Range
With BkMkRng
.Tables(1).Delete
.Text = StrTxt
.Style = "Body Text"
End With
.Bookmarks.Add StrBkMk, BkMkRng
End If
End With
Set BkMkRng = Nothing
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
Perfect -- thank you!
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Word Macro to delete table row and table header | NorthSuffolk | Word VBA | 6 | 10-11-2016 05:04 AM |
How to find and delete duplicate words in doc
|
cinvest | Word | 1 | 09-29-2014 08:34 PM |
| Find and Delete Rows | damaniam | Word VBA | 1 | 03-11-2014 06:54 AM |
find and delete duplicates
|
rcVBA | Word VBA | 4 | 05-15-2013 03:08 PM |
| Find/Delete inline Page #'s | alderfall | Word | 6 | 11-06-2012 11:51 AM |