Solved

Vb.net word tables

Posted on 2014-09-09
3
436 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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

756 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