Solved

Vb.net word tables

Posted on 2014-09-09
3
443 Views
Last Modified: 2014-10-31
Hi,

I have an application I'm using to modify bookmarks in my word document, I was wondering if it was possible to edit a table from vb.net so that I may delete specific cells and rows, certain cells also have split cells... Basically I need to remove everything that has no text in it, would this be possible? It's only one table with multiple rows and split cells

Thank you
0
Comment
Question by:FCapo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 40313036
It is possible to edit tables in code.

However, dealing with tables with an inconsistent number of cells in a row can be tricky, as can tables with an inconsistent number per column. For tables with inconsistency in both directions it is trickiness squared.

Can you post a sample document (redacted if necessary)?
0
 

Author Comment

by:FCapo
ID: 40314708
Yes of course,

here is a sample word document of the table I'm referring too, as you can see it's a table with a maximum of 3 rows, the second and fourth column are split into 4 more rows...

from my program I use bookmarks to replace the "text" with strings from my application. Most of the time the user will not need all 3 rows, and also he may not need all 4 cells split in the second and fourth column. I could always leave it up to the user to the delete the extra "left over" rows and cells, but I figure there may be a better way,

Thank you
sample.doc
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 40315239
Presumably you would need the corresponding cell in column 5 to be deleted as well.

This is actually VBA code, but it shows the idea:
Sub FillBookMark(wdDoc As Word.Document, strBookmarkName As String, strText As String, tbl)
    Dim cl As Word.Cell
    If Len(strText) = 0 Then
        If wdDoc.Bookmarks(strBookmarkName).Range.Cells.Count = 1 Then
            wdDoc.Bookmarks(strBookmarkName).Range.Cells.Delete ShiftCells:=wdDeleteCellsEntireRow
        End If
    Else
        wdDoc.Bookmarks(strBookmarkName).Range.Text = strText
    End If
End Sub

Open in new window

0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question