[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Add a 3 column table to the bottom of a word document using c#

Posted on 2009-05-01
Medium Priority
Last Modified: 2013-11-10
Hi Experts,

I'm attempting to create an ActionsPane in word that will allow users to add comments to a table at the bottom of the document, so that as they are reviewing the document, they can add an entry into the word table by entering the comments in the actionspane and hitting a button.

So how would I go about:
1.  Seeing if a table already exists (lets call it CommentTable); if it does move on to step 2, if not, add the table with 3 columns of 1"; 1",4.5" widths.
2.  Add a new line to the bottom of the table; there will be 3 fields called Section, Reviewer, Comment with data from the actionpane.

Thanks for the help!
Question by:deedub84

Accepted Solution

daluu earned 2000 total points
ID: 24291625
Well, I don't have the time right now and I'm sure other experts might provide you with the needed code examples, but here's a tip on how to get the code yourself:

Use Word macro recorder along with editing or tweaking the VB macro code in Word to do what you want. A trial & error test. Basically the VB macros along with the Word COM API will provide you all the needed methods and properties to add a new line or row to the table or to insert a table with the specified properties. Then once you have the macro code working like the way you kind of want it, you can port the VB code over to C#. Because I'm assuming you are using the Word COM/DLL library, the API calls will be the same, only the syntax is slightly different. There should be Word API reference available in the macro editor, and if not, then online.

One note I'd like to mention though, using Word API in .NET/C#, your API support will be tied to the version of Word that is on your development environment that you will compile the code on. Therefore you might run into problems if your end user has a different version of Word installed. If you ever need broad Word version support, avoid using API calls that are specific to a Word version, or better yet, have the .NET/C# code call a VBScript that will interact with Word, where possible, since the VBScript COM interface is more version lenient than the .NET interface to Word is.

Author Comment

ID: 24294873
Thanks for the tip daluu.  I'm just venturing into the c# world from the vba world and have zero 'court sense' as of yet.  I'll give your suggestions a whirl.


Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Screencast - Getting to Know the Pipeline

834 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