-
Dec 21st, 2008, 06:57 PM
#1
Thread Starter
New Member
Collapsible Microsoft word tables
Hello. I am new here and was referred from another site.
I wanted to know if there was a way to make Collapsible Tables in a Microsoft Word program
i.e. Say I wanted to make a table containing 5 columns and endless rows. Is there a way I could then collapse that table while I work on a new table.
It sounds like it should be a practical thing to do, but I am not sure..
Please Help
-
Dec 21st, 2008, 09:31 PM
#2
Re: Collapsible Microsoft word tables
you could save the table data into an array (or for safety an external file) then delete the table, insert the table back later
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Dec 22nd, 2008, 03:47 AM
#3
Re: Collapsible Microsoft word tables
Welcome to the Forums.
Yes its possible and an interesting idea.
I'm about done with it so I'll post up a FAQ and link it here for you in a few minutes
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Dec 22nd, 2008, 02:40 PM
#4
Thread Starter
New Member
Re: Collapsible Microsoft word tables
Originally Posted by RobDog888
Welcome to the Forums.
Yes its possible and an interesting idea.
I'm about done with it so I'll post up a FAQ and link it here for you in a few minutes
Oh ok thank you very much... I wasn't sure that was something that could be done. But I guess with the right coding, anything is possible.
Allowing for collapsible tables would be beneficial as it would allow one to work on several tables without having to clog up the whole screen...
Please let me know if something that could be done.. I would appreciate it very much.
This forum seems to be filled with Geniuses... I am glad I found it. I have to come in here more often..
-
Dec 22nd, 2008, 04:07 PM
#5
Re: Collapsible Microsoft word tables
I got it working last night but didnt have enough time to clean it up. Its on my system at home so when I get home I will clean it up a bit and post it.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Dec 23rd, 2008, 12:08 AM
#6
Thread Starter
New Member
Re: Collapsible Microsoft word tables
Originally Posted by RobDog888
I got it working last night but didnt have enough time to clean it up. Its on my system at home so when I get home I will clean it up a bit and post it.
Thank you very much. I look forward to seeing how it all works out.
-
Dec 24th, 2008, 12:51 PM
#7
Thread Starter
New Member
Re: Collapsible Microsoft word tables
Hey RobDog888. Any luck at all? Were you able to come up with something?
-
Dec 25th, 2008, 10:46 AM
#8
Fanatic Member
Re: Collapsible Microsoft word tables
It certainly is an interesting idea. I hadn't thought of it before, but it's certainly workable. I wonder how performance would work on larger tables. You could also use hidden fonts to just hide/unhide the table, but that can be thwarted by that pesky show hidden characters button. Then again, Word isn't really a presentation software package so there will always be something that can mess things up with work-arounds.
-
Dec 25th, 2008, 01:28 PM
#9
Re: Collapsible Microsoft word tables
I made this simple macro if this suits your needs.
Just copy & paste this macro in your VBA editor. You may assign it to a toolbar button or keyboard shortcut for ease of use.
Then keep the cursor on any cell in the table you want to expand/collapse and run this macro.
vb Code:
Sub ToggleCollapseTable() Dim tbl As Table Dim newState As Boolean Set tbl = Selection.Tables(1) If tbl Is Nothing Then Exit Sub 'if selection is not a table If tbl.Rows.Count < 2 Then Exit Sub 'if table can't be expanded/collapsed newState = Not tbl.Rows(2).Range.Font.Hidden For i = 2 To tbl.Rows.Count tbl.Rows(i).Range.Font.Hidden = newState Next End Sub
Pradeep
-
Dec 26th, 2008, 03:51 AM
#10
Re: Collapsible Microsoft word tables
Finally done with xmas and stuff.
I finished it the other day but have been away til now. I used the .SetHeight method of the rows to epand and collapse tables. Since in 2007 its alot harder to ass a custom button I used an ActiveX button from the designer and added it to the first row of the table where the table header row is.
Nice code Pradeep
I posted mine on another vb office forum site and can PM you the link (not sure if its cool to post the link) if you want as I'm not sure I will post it in my FAQ here yet. Pradeeps code will do the job on pre-2007 Word.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Jan 21st, 2009, 12:55 PM
#11
Re: Collapsible Microsoft word tables
This one is faster than the one I posted earlier and has the same effect, since it doesn't have to loop through the table rows:
vb Code:
Sub ToggleCollapseTable() Dim tbl As Table, rng As Range Dim newState As Boolean Set tbl = Selection.Tables(1) If tbl Is Nothing Then Exit Sub 'if selection is not a table If tbl.Rows.Count < 2 Then Exit Sub 'if table can't be expanded/collapsed Set rng = tbl.Rows(2).Range newState = Not rng.Font.Hidden rng.MoveEnd Unit:=wdTable, Count:=1 rng.Font.Hidden = newState End Sub
Pradeep
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
|