Solved

Vb.net word tables

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

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

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

A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

729 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