|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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! |
#2
|
|||
|
|||
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 |
#3
|
|||
|
|||
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. |
#4
|
||||
|
||||
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 |
#5
|
|||
|
|||
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 |
#6
|
|||
|
|||
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 |
#7
|
|||
|
|||
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!
|
#8
|
||||
|
||||
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 |
#9
|
|||
|
|||
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! |
#10
|
||||
|
||||
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 |
#11
|
|||
|
|||
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!
|
#12
|
||||
|
||||
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 |
#13
|
|||
|
|||
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! |
#14
|
||||
|
||||
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 |
|
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 |
One Content Control Checkbox checks another Content Control Checkbox | DEsh | Word VBA | 2 | 10-06-2017 08:23 PM |
Clicking the selected Content Control checkbox returns wrong control in vba event | DougsGraphics | Word VBA | 2 | 06-24-2015 07:31 AM |
Deleting a table from a content control -- preserving the content control | BrainSlugs83 | Word Tables | 8 | 11-14-2013 03:06 AM |