Wrox Programmer Forums
Word VBA Discuss using VBA to program Word.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Word VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 27th, 2018, 05:02 PM
Registered User
Join Date: Jun 2018
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Delete Table VBA Help

Hi, I am designing a word document and hoping someone can help me with a VBA that I am stuck on.

I have a command button at the top of the document to delete a table and I am trying to programme the macro so that whichever table the cursor is in is deleted when the button is pressed.

I am aware that all the tables are indexed so my current plan is to count the table number of which I currently have the following code:

Sub tabnum()

Dim tabnum
tabnum = ActiveDocument.Range(0, Selection.Tables(1).Range.End).Tables.Count

End Sub

This works and calculate the current tables index number, however I am struggling for where to go from there to actually delete that table

I believe it will be something like selection.tables(tabnum).delete however that doesn't work.

Many thanks for any help


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA code to search for a range and delete other cells idys Excel VBA 1 November 20th, 2016 06:08 AM
VBA to create and delete shapes jbburf Excel VBA 1 September 25th, 2012 05:57 PM
Using VBA to insert or delete row and column automatic hpmongmanh Excel VBA 0 December 15th, 2010 11:01 AM
delete a user form using vba sms Access VBA 2 June 27th, 2008 07:15 AM
Access VBA Delete Query Issue... snoopy92211 Access VBA 4 June 24th, 2004 03:57 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.