Results 1 to 2 of 2

Thread: [RESOLVED] VB.net Word interop Templates - Deleting tables programmatically from templates?

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2018
    Posts
    2

    Resolved [RESOLVED] VB.net Word interop Templates - Deleting tables programmatically from templates?

    Hi I am just an amateur programmer that has been using VB since vb4. Usually for fun but I have been working on a program for about a year now that needs to generate a MS Word report that will have paragraphs and tables in it. (The program will output an attending physician’s report.) I have found the documentation on this to be lacking to a degree. I am using Visual Studio 2017 and MS office 2016 and my program is a windows form program.

    My question is this, my document will have the possibility of using up to 20 tables but most commonly will only have two. They are easy to create in word as part of template but I cannot figure out how to delete the ones that I will not be using in the template.

    They are a bit of a pain in the neck to create programmatically as the creation is verbose code wise but I pretty much have figured out how to do this if it is what I need to do. It just seems rather inelegant when it is so easy to do via a template.

    Hoping for a bit of advice as to which way to go. (and / or a hint or example or link to a website that has an example of programmatically deleting tables from a website if possible...or anything useful.) Thanks a whole bunch!

  2. #2

    Thread Starter
    New Member
    Join Date
    Feb 2018
    Posts
    2

    Re: VB.net Word interop Templates - Deleting tables programmatically from templates?

    I figured it out ....sadly super easy. (I was thinking of the container ..borders shading etc differently than the table itself.)
    ' If oDoc.Tables.Count <> 0 Then
    ' oDoc.Tables(1).Delete()
    ' End If
    will do it for me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width