VBA & Macro Problems

WPS Writer VBA Macro to Hide and Show a Table

Huda QurayshiHuda Qurayshi Nov 13, 2026 869 views

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.
Before you start

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.

Solution 1Recommended

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.

1
Insert a bookmark around the table

In WPS Writer, select the whole table, click Insert > Bookmark, type Census, and click Add.

2
Open the VBA editor

Click the Developer tab and then click Visual Basic to open the Visual Basic for Applications editor.

3
Run the hide macro

Use ActiveDocument.Bookmarks("Census").Range.Font.Hidden = True to hide the bookmarked table contents.

4
Run the show macro

Use ActiveDocument.Bookmarks("Census").Range.Font.Hidden = False to show the table again.

Macro range works reliably: Using a bookmark avoids relying on table style visibility and targets only the table contents you selected.
WPS Writer VBA macro

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. 1. Open WPS Writer and the VBA editor: Open your document in WPS Writer, click the Developer tab, then click Visual Basic.
  2. 2. Insert a table bookmark: In the document, select the entire table, click Insert > Bookmark, name it Census, and click Add.
  3. 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. 4. Run the macro: Close the VBA editor, click Developer > Macros, select the macro, and click Run.
Targets only the bookmarked table so other content remains visibleSupports Word VBA macro syntax including ActiveDocument.BookmarksMaintains compatibility with Microsoft Word .docm and .docx documentsFree to use in WPS Office with a familiar ribbon and VBA editor
microsoft office alternative - wps office

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.