Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-13-2019, 02:25 PM
mahaabub mahaabub is offline Show/Delete paragraph based on checkbox status Windows 10 Show/Delete paragraph based on checkbox status Office 2013
Novice
Show/Delete paragraph based on checkbox status
 
Join Date: May 2019
Location: Toronto
Posts: 2
mahaabub is on a distinguished road
Default Show/Delete paragraph based on checkbox status

Hi,



I am trying to automate an employment contract. One of the specification is that for some employment positions, the contract needs to specify 1-2 extra items.

So, I need to code a checkbox to either show these paragraphs or delete them (see attachment). If the paragraphs are not needed, then the bullet points need to be rearranged so that there are no space, and the numbering continues.

So, in the picture, if the check box was not selected, i need to see only 3 paragraphs numbered a, b, c.

I have tried to use show/hide text using activex checkbox. It did not solve the numbering issue. also, when i use hide text, it leaves blank space where the paragraphs are hidden.

Any help would be very much appreciated.

Thank you.

Mahabub
Attached Images
File Type: png VBA Macro.png (82.4 KB, 26 views)
Reply With Quote
  #2  
Old 05-13-2019, 05:33 PM
gmaxey gmaxey is offline Show/Delete paragraph based on checkbox status Windows 10 Show/Delete paragraph based on checkbox status Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,422
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Wrap your conditional text is a rich text content control e.g., title it "Kill me"


Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim bCheck As Boolean
Dim oRng As Range
  bCheck = False 'Simulates your check box unchecked state.
  If Not bCheck Then
    Set oRng = ActiveDocument.SelectContentControlsByTitle("Kill me").Item(1).Range.Paragraphs(1).Range
    ActiveDocument.SelectContentControlsByTitle("Kill me").Item(1).Delete True
    oRng.Delete
  End If
lbl_Exit:
  Exit Sub
  
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Apply a formula or not depending on checkbox status 14spar15 Excel 1 10-12-2018 01:14 PM
Bookmark will not show/hide based on CC Checkbox lord_kaiser Word VBA 1 04-17-2018 01:19 AM
Show/Delete paragraph based on checkbox status Hide/Show text based upon check box status nathan.gray@emerson.com Word VBA 5 12-08-2017 01:08 PM
Show/Delete paragraph based on checkbox status Show current section in status bar Phil H Word 2 02-02-2016 01:45 PM
Show/Delete paragraph based on checkbox status Show/Hide Text based on Checkbox Selection tammytran105 Word VBA 7 10-02-2014 04:30 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:25 PM.


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