Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Other Office > Word VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 27th, 2018, 05:02 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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

Andy
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 05: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 10: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



All times are GMT -4. The time now is 12:10 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.