Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.tables
|
|||
|
|||
![]()
I have a table that has 3 columns - sometimes I need the last column and
sometimes I don't. Is it possible to put a formfield checkbox at the top of the column so that if it is not checked, the column will be deleted? Likewise, some of the rows may be needed, some may not. Can I also put a checkbox in front of each row to control which can be deleted and which cannot? |
#2
![]()
Posted to microsoft.public.word.tables
|
|||
|
|||
![]()
The problem with doing that sort of thing is that there is no going back if
you change your mind. The following code run on exit from the checkbox will however give you a chance to change your mind: Dim Response With ActiveDocument If .FormFields("Check1").CheckBox.Value = True Then Response = MsgBox("Are you sure that you want to delete the column?", vbQuestion + vbYesNo) If Response = vbYes Then .Unprotect .Tables(1).Columns(3).Delete .Protect wdAllowOnlyFormFields, NoReset End If End If End With -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "sg" wrote in message ... I have a table that has 3 columns - sometimes I need the last column and sometimes I don't. Is it possible to put a formfield checkbox at the top of the column so that if it is not checked, the column will be deleted? Likewise, some of the rows may be needed, some may not. Can I also put a checkbox in front of each row to control which can be deleted and which cannot? |
#3
![]()
Posted to microsoft.public.word.tables
|
|||
|
|||
![]()
That is awesome. Thank you!
"Doug Robbins - Word MVP" wrote: The problem with doing that sort of thing is that there is no going back if you change your mind. The following code run on exit from the checkbox will however give you a chance to change your mind: Dim Response With ActiveDocument If .FormFields("Check1").CheckBox.Value = True Then Response = MsgBox("Are you sure that you want to delete the column?", vbQuestion + vbYesNo) If Response = vbYes Then .Unprotect .Tables(1).Columns(3).Delete .Protect wdAllowOnlyFormFields, NoReset End If End If End With -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "sg" wrote in message ... I have a table that has 3 columns - sometimes I need the last column and sometimes I don't. Is it possible to put a formfield checkbox at the top of the column so that if it is not checked, the column will be deleted? Likewise, some of the rows may be needed, some may not. Can I also put a checkbox in front of each row to control which can be deleted and which cannot? |
#4
![]()
Posted to microsoft.public.word.tables
|
|||
|
|||
![]()
If I could bother you again...
I tweaked the code you gave me to also delete a row in the same table if the checkbox is not checked. Is there a way to specify that it should be the row that the checkbox is in instead of specifying row 2 or row 3? "Doug Robbins - Word MVP" wrote: The problem with doing that sort of thing is that there is no going back if you change your mind. The following code run on exit from the checkbox will however give you a chance to change your mind: Dim Response With ActiveDocument If .FormFields("Check1").CheckBox.Value = True Then Response = MsgBox("Are you sure that you want to delete the column?", vbQuestion + vbYesNo) If Response = vbYes Then .Unprotect .Tables(1).Columns(3).Delete .Protect wdAllowOnlyFormFields, NoReset End If End If End With -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "sg" wrote in message ... I have a table that has 3 columns - sometimes I need the last column and sometimes I don't. Is it possible to put a formfield checkbox at the top of the column so that if it is not checked, the column will be deleted? Likewise, some of the rows may be needed, some may not. Can I also put a checkbox in front of each row to control which can be deleted and which cannot? |
#5
![]()
Posted to microsoft.public.word.tables
|
|||
|
|||
![]()
Selection.Rows(1).Delete
-- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "sg" wrote in message ... If I could bother you again... I tweaked the code you gave me to also delete a row in the same table if the checkbox is not checked. Is there a way to specify that it should be the row that the checkbox is in instead of specifying row 2 or row 3? "Doug Robbins - Word MVP" wrote: The problem with doing that sort of thing is that there is no going back if you change your mind. The following code run on exit from the checkbox will however give you a chance to change your mind: Dim Response With ActiveDocument If .FormFields("Check1").CheckBox.Value = True Then Response = MsgBox("Are you sure that you want to delete the column?", vbQuestion + vbYesNo) If Response = vbYes Then .Unprotect .Tables(1).Columns(3).Delete .Protect wdAllowOnlyFormFields, NoReset End If End If End With -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "sg" wrote in message ... I have a table that has 3 columns - sometimes I need the last column and sometimes I don't. Is it possible to put a formfield checkbox at the top of the column so that if it is not checked, the column will be deleted? Likewise, some of the rows may be needed, some may not. Can I also put a checkbox in front of each row to control which can be deleted and which cannot? |
#6
![]()
Posted to microsoft.public.word.tables
|
|||
|
|||
![]()
Well...I tried that - put it in place of .Tables(1).Rows(2).Delete. I got an
error then that said the requested member of the collection does not exist. Then I changed the code so it read .Tables(1).Selection.Rows(1).Delete, but I still get an error. What am I doing wrong? "Doug Robbins - Word MVP" wrote: Selection.Rows(1).Delete -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "sg" wrote in message ... If I could bother you again... I tweaked the code you gave me to also delete a row in the same table if the checkbox is not checked. Is there a way to specify that it should be the row that the checkbox is in instead of specifying row 2 or row 3? "Doug Robbins - Word MVP" wrote: The problem with doing that sort of thing is that there is no going back if you change your mind. The following code run on exit from the checkbox will however give you a chance to change your mind: Dim Response With ActiveDocument If .FormFields("Check1").CheckBox.Value = True Then Response = MsgBox("Are you sure that you want to delete the column?", vbQuestion + vbYesNo) If Response = vbYes Then .Unprotect .Tables(1).Columns(3).Delete .Protect wdAllowOnlyFormFields, NoReset End If End If End With -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "sg" wrote in message ... I have a table that has 3 columns - sometimes I need the last column and sometimes I don't. Is it possible to put a formfield checkbox at the top of the column so that if it is not checked, the column will be deleted? Likewise, some of the rows may be needed, some may not. Can I also put a checkbox in front of each row to control which can be deleted and which cannot? |
#7
![]()
Posted to microsoft.public.word.tables
|
|||
|
|||
![]()
You need to use:
Dim Response With ActiveDocument If .FormFields("Check1").CheckBox.Value = True Then Response = MsgBox("Are you sure that you want to delete the column?", vbQuestion + vbYesNo) If Response = vbYes Then .Unprotect .FormFields("check1").Range.Rows(1).Delete ' .Tables(1).Columns(3).Delete .Protect wdAllowOnlyFormFields, NoReset End If End If End With -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "sg" wrote in message news ![]() Well...I tried that - put it in place of .Tables(1).Rows(2).Delete. I got an error then that said the requested member of the collection does not exist. Then I changed the code so it read .Tables(1).Selection.Rows(1).Delete, but I still get an error. What am I doing wrong? "Doug Robbins - Word MVP" wrote: Selection.Rows(1).Delete -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "sg" wrote in message ... If I could bother you again... I tweaked the code you gave me to also delete a row in the same table if the checkbox is not checked. Is there a way to specify that it should be the row that the checkbox is in instead of specifying row 2 or row 3? "Doug Robbins - Word MVP" wrote: The problem with doing that sort of thing is that there is no going back if you change your mind. The following code run on exit from the checkbox will however give you a chance to change your mind: Dim Response With ActiveDocument If .FormFields("Check1").CheckBox.Value = True Then Response = MsgBox("Are you sure that you want to delete the column?", vbQuestion + vbYesNo) If Response = vbYes Then .Unprotect .Tables(1).Columns(3).Delete .Protect wdAllowOnlyFormFields, NoReset End If End If End With -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "sg" wrote in message ... I have a table that has 3 columns - sometimes I need the last column and sometimes I don't. Is it possible to put a formfield checkbox at the top of the column so that if it is not checked, the column will be deleted? Likewise, some of the rows may be needed, some may not. Can I also put a checkbox in front of each row to control which can be deleted and which cannot? |
#8
![]()
Posted to microsoft.public.word.tables
|
|||
|
|||
![]()
Thanks! That is absolutely perfect!!
"Doug Robbins - Word MVP" wrote: You need to use: Dim Response With ActiveDocument If .FormFields("Check1").CheckBox.Value = True Then Response = MsgBox("Are you sure that you want to delete the column?", vbQuestion + vbYesNo) If Response = vbYes Then .Unprotect .FormFields("check1").Range.Rows(1).Delete ' .Tables(1).Columns(3).Delete .Protect wdAllowOnlyFormFields, NoReset End If End If End With -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "sg" wrote in message news ![]() Well...I tried that - put it in place of .Tables(1).Rows(2).Delete. I got an error then that said the requested member of the collection does not exist. Then I changed the code so it read .Tables(1).Selection.Rows(1).Delete, but I still get an error. What am I doing wrong? "Doug Robbins - Word MVP" wrote: Selection.Rows(1).Delete -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "sg" wrote in message ... If I could bother you again... I tweaked the code you gave me to also delete a row in the same table if the checkbox is not checked. Is there a way to specify that it should be the row that the checkbox is in instead of specifying row 2 or row 3? "Doug Robbins - Word MVP" wrote: The problem with doing that sort of thing is that there is no going back if you change your mind. The following code run on exit from the checkbox will however give you a chance to change your mind: Dim Response With ActiveDocument If .FormFields("Check1").CheckBox.Value = True Then Response = MsgBox("Are you sure that you want to delete the column?", vbQuestion + vbYesNo) If Response = vbYes Then .Unprotect .Tables(1).Columns(3).Delete .Protect wdAllowOnlyFormFields, NoReset End If End If End With -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "sg" wrote in message ... I have a table that has 3 columns - sometimes I need the last column and sometimes I don't. Is it possible to put a formfield checkbox at the top of the column so that if it is not checked, the column will be deleted? Likewise, some of the rows may be needed, some may not. Can I also put a checkbox in front of each row to control which can be deleted and which cannot? |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Three-column table on two-column page won't balance correctly | New Users | |||
Multi-column pages. Need to leave 3rd column blank | Microsoft Word Help | |||
How do I change a text column to a number column when merging? | Microsoft Word Help | |||
the word document has a left side column i need to delete. | New Users | |||
How to paste a column of text into a column in a Word Table | Page Layout |