Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-29-2023, 03:28 PM
AVarg123 AVarg123 is offline Adjust content antd line spacing in word table according to checkbox content control state Windows 10 Adjust content antd line spacing in word table according to checkbox content control state Office 2016
Novice
Adjust content antd line spacing in word table according to checkbox content control state
 
Join Date: Dec 2021
Posts: 15
AVarg123 is on a distinguished road
Default Adjust content antd line spacing in word table according to checkbox content control state


I have a table with 13 rows and 2 columns. The first column has a
ContentControl and 2nd column have the text. All unchecked ContentControl should hide/delete the entire row on the table and adjust the space automatically. The final document should have all checked text (row) regardless of the order the user selects. I got the code but the table border is not deleting. Would appreciate any response. Thank you!
Reply With Quote
  #2  
Old 12-30-2023, 08:18 AM
Charles Kenyon Charles Kenyon is offline Adjust content antd line spacing in word table according to checkbox content control state Windows 11 Adjust content antd line spacing in word table according to checkbox content control state Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,140
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

I moved your post into the Word vba forum.
You say you have the code. Would you perhaps want to share what code you are using?
How to post a question on this MSOffice forum
Reply With Quote
  #3  
Old 01-02-2024, 11:40 AM
AVarg123 AVarg123 is offline Adjust content antd line spacing in word table according to checkbox content control state Windows 10 Adjust content antd line spacing in word table according to checkbox content control state Office 2016
Novice
Adjust content antd line spacing in word table according to checkbox content control state
 
Join Date: Dec 2021
Posts: 15
AVarg123 is on a distinguished road
Default

This is the code I am using. This code will hide the text when I uncheck the ContentControl.

Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)

If ContentControl.Tag <> "" Then
ActiveDocument.Bookmarks(ContentControl.Tag).Range .Font.Hidden = Not ContentControl.Checked

End If

Issue is: table border will not hide with this code, even though no border style has been selected. pic attached.
Attached Images
File Type: png pic.png (34.8 KB, 21 views)
Reply With Quote
  #4  
Old 01-03-2024, 02:59 AM
Guessed's Avatar
Guessed Guessed is offline Adjust content antd line spacing in word table according to checkbox content control state Windows 10 Adjust content antd line spacing in word table according to checkbox content control state Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Try this instead
Code:
Private Sub Document_ContentControlOnExit(ByVal aCC As ContentControl, Cancel As Boolean)
  If aCC.Type = wdContentControlCheckBox Then
    aCC.Range.Rows(1).Range.Font.Hidden = Not aCC.Checked
  End If
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #5  
Old 01-03-2024, 03:03 AM
Italophile Italophile is offline Adjust content antd line spacing in word table according to checkbox content control state Windows 11 Adjust content antd line spacing in word table according to checkbox content control state Office 2021
Expert
 
Join Date: Mar 2022
Posts: 338
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

Your code is failing because the bookmark doesn't enclose the entire row, though you don't need the bookmark as you can access the row directly through the content controls range.

Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
    With ContentControl
        If .Range.Information(wdWithInTable) Then
            .Range.Rows(1).Range.Font.Hidden = Not .Checked
        End If
    End With
End Sub
Reply With Quote
  #6  
Old 01-03-2024, 03:35 PM
AVarg123 AVarg123 is offline Adjust content antd line spacing in word table according to checkbox content control state Windows 10 Adjust content antd line spacing in word table according to checkbox content control state Office 2016
Novice
Adjust content antd line spacing in word table according to checkbox content control state
 
Join Date: Dec 2021
Posts: 15
AVarg123 is on a distinguished road
Default

Thank you!
The below code worked.

Private Sub Document_ContentControlOnExit(ByVal aCC As ContentControl, Cancel As Boolean)
If aCC.Type = wdContentControlCheckBox Then
aCC.Range.Rows(1).Range.Font.Hidden = Not aCC.Checked
End If
End Sub
Reply With Quote
  #7  
Old 01-03-2024, 04:25 PM
AVarg123 AVarg123 is offline Adjust content antd line spacing in word table according to checkbox content control state Windows 10 Adjust content antd line spacing in word table according to checkbox content control state Office 2016
Novice
Adjust content antd line spacing in word table according to checkbox content control state
 
Join Date: Dec 2021
Posts: 15
AVarg123 is on a distinguished road
Default

I am opening this macro-enabled document from a web application. All ContnentControls are disabled when I open the document. Not sure of the reason. Any help would be helpful. Thank you!
Reply With Quote
  #8  
Old 01-06-2024, 04:23 PM
Guessed's Avatar
Guessed Guessed is offline Adjust content antd line spacing in word table according to checkbox content control state Windows 10 Adjust content antd line spacing in word table according to checkbox content control state Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

There is a big risk that macros contained in files you access/download from a web application so Microsoft disables the macros. This protects users from malicious code running without their explicit approvals.

Are you needing this macro to run just on your machine or does it need to work on unknown users machines? I would probably put the macros in a template which is already on the machine and make that template the 'attached template' so that when the file is opened, it runs the macros from a pre-trusted location.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #9  
Old 01-08-2024, 11:18 AM
AVarg123 AVarg123 is offline Adjust content antd line spacing in word table according to checkbox content control state Windows 10 Adjust content antd line spacing in word table according to checkbox content control state Office 2016
Novice
Adjust content antd line spacing in word table according to checkbox content control state
 
Join Date: Dec 2021
Posts: 15
AVarg123 is on a distinguished road
Default

16 users are downloading this macro-enabled document from the web application.

I never created macros in a template. Are you suggesting to save as a .dotm document? All macros are disabled when I try to save as a .dotx file.

Would you please provide more guidance?
Thank you!
Reply With Quote
  #10  
Old 01-08-2024, 03:18 PM
Guessed's Avatar
Guessed Guessed is offline Adjust content antd line spacing in word table according to checkbox content control state Windows 10 Adjust content antd line spacing in word table according to checkbox content control state Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Yes, you would need to save the file as a .dotm and have this file placed in the user's machines (in their User Templates folder). They can then create new docx files from that template by using File>New or you could use it to create a .docx and put that file on your web interface. Word will then find the 'attached template' and its code when that document is opened on any machine that has the template installed.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #11  
Old 01-09-2024, 12:57 PM
AVarg123 AVarg123 is offline Adjust content antd line spacing in word table according to checkbox content control state Windows 10 Adjust content antd line spacing in word table according to checkbox content control state Office 2016
Novice
Adjust content antd line spacing in word table according to checkbox content control state
 
Join Date: Dec 2021
Posts: 15
AVarg123 is on a distinguished road
Default

Hello, Users do not have access to add this form to the web application. They should open the form from the selection box built into the application. So placing the file in each user's machine is not practicable. The issue is none of the content controls on the form are working when open in the web browser, but all checkboxes are working. Should I change my content controls to check boxes? Please advise. Thank you!
Reply With Quote
  #12  
Old 01-09-2024, 04:49 PM
Guessed's Avatar
Guessed Guessed is offline Adjust content antd line spacing in word table according to checkbox content control state Windows 10 Adjust content antd line spacing in word table according to checkbox content control state Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

If this functionality is required to work from a web application then I think that Word is a poor choice because you are asking for automation that requires trust levels.

I would recommend you either forget about hiding content dynamically in a Word version of the form OR recreate it as a dynamic PDF or html-based form.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #13  
Old 01-10-2024, 01:30 PM
AVarg123 AVarg123 is offline Adjust content antd line spacing in word table according to checkbox content control state Windows 10 Adjust content antd line spacing in word table according to checkbox content control state Office 2016
Novice
Adjust content antd line spacing in word table according to checkbox content control state
 
Join Date: Dec 2021
Posts: 15
AVarg123 is on a distinguished road
Default

Hello Andrew, Thank you for your recommendation. Unfortunately, the application will accept only Word file formats. Also, I never created (don't know how) a html-based form.
Thank you for all your help!
Reply With Quote
  #14  
Old 01-10-2024, 03:36 PM
Guessed's Avatar
Guessed Guessed is offline Adjust content antd line spacing in word table according to checkbox content control state Windows 10 Adjust content antd line spacing in word table according to checkbox content control state Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Sorry we couldn't help you. The trickier functionality of Word (like macros) can only work when the file is opened in the desktop application. Nowdays, browsers and web apps let you see/edit the content inside a browser which can restrict your functionality
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hiding rich text content control using checkbox - Removing extra spacing TheOstrich Word VBA 4 11-15-2023 11:58 AM
Adjust content antd line spacing in word table according to checkbox content control state One Content Control Checkbox checks another Content Control Checkbox DEsh Word VBA 2 10-06-2017 08:23 PM
Adjust content antd line spacing in word table according to checkbox content control state Clicking the selected Content Control checkbox returns wrong control in vba event DougsGraphics Word VBA 2 06-24-2015 07:31 AM
Adjust content antd line spacing in word table according to checkbox content control state Deleting a table from a content control -- preserving the content control BrainSlugs83 Word Tables 8 11-14-2013 03:06 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:24 AM.


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