WPS Writer VBA Macro to Hide and Show a Table
Question details
The user needs a working Word VBA macro in WPS Writer to hide and show a table, because the style Visibility property only controls the Styles gallery.
- Product
- WPS Office Writer
- Device & OS
- not provided
- Scenario
- The user is editing a VBA macro that should control table visibility in a Writer document.
- Observed behavior
- The macro ActiveDocument.Styles(Word.Table).Visibility = True does not hide or show the table.
Open WPS Writer and make sure the Developer tab is visible in the ribbon. Select the entire table and insert a bookmark around it before editing or running the macro.
Hide and Show a Table with a Bookmark and Font.Hidden
Use this when you need a reliable macro that actually hides the table contents instead of changing a style gallery setting.
The Style.Visibility property only controls whether a style is listed in the Styles gallery, not whether document content is visible. A bookmark gives the macro a stable range that can be hidden or shown even if the table moves during editing.
In WPS Writer, select the whole table, click Insert > Bookmark, type Census, and click Add.
Click the Developer tab and then click Visual Basic to open the Visual Basic for Applications editor.
Use ActiveDocument.Bookmarks("Census").Range.Font.Hidden = True to hide the bookmarked table contents.
Use ActiveDocument.Bookmarks("Census").Range.Font.Hidden = False to show the table again.
Toggle Table Visibility with a Single Macro
Use this when you want one macro to switch the table between hidden and visible states.
Use a Bookmark Macro in WPS Writer to Hide and Show a Table
WPS Writer supports Word-compatible VBA macros, so you can replace the ineffective table style Visibility call with a bookmark-based macro. This method hides and restores the selected table contents without changing the document structure.
- 1. Open WPS Writer and the VBA editor: Open your document in WPS Writer, click the Developer tab, then click Visual Basic.
- 2. Insert a table bookmark: In the document, select the entire table, click Insert > Bookmark, name it Census, and click Add.
- 3. Add the hide and show macro code: In the VBA editor, insert a module and enter the macro that sets ActiveDocument.Bookmarks("Census").Range.Font.Hidden = True or False.
- 4. Run the macro: Close the VBA editor, click Developer > Macros, select the macro, and click Run.

Frequently Asked Questions
Why does ActiveDocument.Styles(Word.Table).Visibility = True not hide my table?
Because the Visibility property controls whether the style appears in the Styles gallery and Styles pane, not whether table content is hidden. Use a bookmark and set Range.Font.Hidden instead.
How do I bookmark a whole table in WPS Writer?
Select the entire table, click Insert > Bookmark, enter a name such as Census, and click Add. Then use that bookmark name in your VBA code.
Can I toggle the table visibility with one macro?
Yes. Use ActiveDocument.Bookmarks("Census").Range.Font.Hidden = Not ActiveDocument.Bookmarks("Census").Range.Font.Hidden to switch between hidden and visible.
Does this VBA bookmark method work with Word .docm files in WPS Writer?
Yes. WPS Writer supports Word-compatible VBA macro syntax and can open .docm files, so the same bookmark range code can be used.




