-
October 21st, 2014, 07:03 PM
#1
Toggle Buttons hides/unhides a table below it (word VBA mso 7)
Hey all
I am trying to make a toggle button next to the title of the table, in this case "Family Information" hide and unhide the table below. So basically it toggles if that table is hidden or viewed, and the toggle button caption is "+ / -"
I want the code to recognise the title text above the table, so that the one table below that text is what is hidden or unhidden. This is what I have so far but it's not working. I think it's the with selection part that is not correct.
Code:
Sub ToggleButton112_Change()
Call ShowHideGoals1
End Sub
'''' Start hiding family table based off toggle button
Sub ShowHideGoals1()
With Selection
.GoTo What:=wdGoToTable, Which:=wdGoToFirst, _
Count:=2, Name:="Family Information"
.Tables(1).Cell(1, 1).Range.Select
End With
If ToggleButton112.Value = True Then
With Selection.Font
.Hidden = True
End With
With ActiveWindow.View
.ShowHiddenText = False
.ShowAll = False
End With
Else
With Selection.Font
.Hidden = False
End With
With ActiveWindow.View
.ShowHiddenText = True
.ShowAll = True
End With
With Selection
.Collapse direction:=wdCollapseStart
.MoveLeft unit:=wdCharacter, Count:=1
End With
End If
End Sub
-
October 21st, 2014, 08:51 PM
#2
Re: Toggle Buttons hides/unhides a table below it (word VBA mso 7)
cool, got it working.
Code:
Sub ShowHideGoals1()
With Selection
.GoTo What:=wdGoToTable, Which:=wdGoToFirst, Count:=3
.Tables(1).Range.Select
End With
If ToggleButton112.Value = True Then
With Selection.Font
.Hidden = True
End With
With ActiveWindow.View
.ShowHiddenText = False
.ShowAll = False
.ShowParagraphs = False
End With
Else
With Selection.Font
.Hidden = False
End With
With ActiveWindow.View
.ShowHiddenText = True
.ShowAll = True
.ShowParagraphs = True
End With
With Selection
.Collapse direction:=wdCollapseStart
.MoveLeft unit:=wdCharacter, Count:=1
End With
With ActiveWindow.View
.ShowParagraphs = False
.ShowAll = False
End With
End If
End Sub
All good, thanks
-
October 21st, 2014, 09:07 PM
#3
Re: Toggle Buttons hides/unhides a table below it (word VBA mso 7)
Now I have the problem that when I have both tables hidden, and I click to unhide the first table (togglebutton11), it unhides both tables.. I'm not sure why, but it must have both tables selected for some reason.
Code:
'initiates client info hide
Sub ToggleButton11_Change()
Call ShowHideGoals2
End Sub
'initiates family info info hide
Sub ToggleButton112_Change()
Call ShowHideGoals1
End Sub
'''' hide client info based off toggle button
Sub ShowHideGoals2()
With Selection
.GoTo What:=wdGoToTable, Which:=wdGoToFirst, Count:=2
.Tables(1).Range.Select
End With
If ToggleButton11.Value = True Then
With Selection.Font
.Hidden = True
End With
With ActiveWindow.View
.ShowHiddenText = False
.ShowAll = False
.ShowParagraphs = False
End With
Else
With Selection.Font
.Hidden = False
End With
With ActiveWindow.View
.ShowHiddenText = True
.ShowAll = True
.ShowParagraphs = True
End With
With Selection
.Collapse direction:=wdCollapseStart
.MoveLeft unit:=wdCharacter, Count:=1
End With
With ActiveWindow.View
.ShowParagraphs = False
.ShowAll = False
End With
End If
End Sub
'''' hide family table based off toggle button
Sub ShowHideGoals1()
With Selection
.GoTo What:=wdGoToTable, Which:=wdGoToFirst, Count:=3
.Tables(1).Range.Select
End With
If ToggleButton112.Value = True Then
With Selection.Font
.Hidden = True
End With
With ActiveWindow.View
.ShowHiddenText = False
.ShowAll = False
End With
Else
With Selection.Font
.Hidden = False
End With
With ActiveWindow.View
.ShowHiddenText = True
.ShowAll = True
End With
With Selection
.Collapse direction:=wdCollapseStart
.MoveLeft unit:=wdCharacter, Count:=1
End With
With ActiveWindow.View
.ShowParagraphs = False
.ShowAll = False
End With
End If
End Sub
-
October 21st, 2014, 09:11 PM
#4
Re: Toggle Buttons hides/unhides a table below it (word VBA mso 7)
Is there a way to just hide a table under particular words?? This table count isn't very efficient. So if i could just hide a table under the title "blah" would be good
-
October 22nd, 2014, 10:11 PM
#5
Re: Toggle Buttons hides/unhides a table below it (word VBA mso 7)
Just set up a few flags, and use them instead. Shouldn't be too difficult to keep things apart. Could use =1 =2 =3 or BOOLEAN
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|