Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-29-2017, 01:25 PM
kevinbradley57 kevinbradley57 is offline Replace a named table with text Windows 7 64bit Replace a named table with text Office 2010 64bit
Advanced Beginner
Replace a named table with text
 
Join Date: Jul 2017
Posts: 89
kevinbradley57 is on a distinguished road
Default Replace a named table with text


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
Reply With Quote
  #2  
Old 08-31-2017, 05:13 AM
macropod's Avatar
macropod macropod is offline Replace a named table with text Windows 7 64bit Replace a named table with text Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,367
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 08-31-2017, 07:49 AM
kevinbradley57 kevinbradley57 is offline Replace a named table with text Windows 7 64bit Replace a named table with text Office 2010 64bit
Advanced Beginner
Replace a named table with text
 
Join Date: Jul 2017
Posts: 89
kevinbradley57 is on a distinguished road
Default

Perfect -- thank you!
Reply With Quote
Reply



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
Replace a named table with text 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
Replace a named table with text 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

Other Forums: Access Forums

All times are GMT -7. The time now is 10:01 AM.


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