#1
|
|||
|
|||
Using programming with Word Templates
Hi, I want to create a MSWord template, marking sections in which I want to edit later with C#.
For example, I want to add a custom table in a specific part of the document. This table needs to have variable row numbers, depending on how much information I need to print. Also, I want to add is a custom image in a specific part. I need to mark a position in which I will insert an image later with C#. Don't know if it is clear, but can someone give me some hints on how to accomplish that? Should I use merge fields, content control or other feature, and later edit those with C#? Thanks in advance! |
#2
|
|||
|
|||
Hi
Suggest you post this in the Word VBA Section. Tony |
#3
|
||||
|
||||
But it isn't a vba question. That said, there are plenty of useful programming examples in the VBA forum, especially, showing how to work with Word's object model.
vmsobral: You refer to c#, which I'm not sure anyone here knows much about. As for: Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
|||
|
|||
First, thanks for the answers.
What I am trying to accomplish is editing a document template via a software I am developing, and that is all. C# is probably the language that I am going to use. I am supposing that the editable parts are fixed in the document. Thus, the thing is that I just wanted to know what is the best way to mark these parts, so I can locate/edit them later via programming. Also, I am open to sugestions on how to produce this customizable fields for tables an images. I will take a look at VBA, but since I am expecting to use C# I don't know if it will fit my needs. Thanks again! |
#5
|
||||
|
||||
You have numerous options for programmatic editing, none of which is necessarily 'the best', including:
• editing Word's built-in document properties, combined with DOCPROPERTY fields in the document; • creating/editing custom document properties, combined with DOCPROPERTY fields in the document; • using bookmarks, also possibly combined with cross-reference fields; • using tables, formfields or content controls (the latter are usable only in Word 2007 & later) as placeholders; • using embedded objects (eg Excel workbooks) or linking to external objects (eg Excel workbooks, other documents, etc). • using custom Quick Parts that can be used to add whole pages/sections of content, if need be, as/when required. It's not really a question of working with vba, but with the Word object model. All of that model's properties, procedures and methods are, of course, exposed to vba. If you're working in C#, it them becomes a matter of learning how to automate Word and call the Word object model to do whatever you need. PS: There are many C# code snippets for Office automation at the MSDN library: http://msdn.microsoft.com/en-US/ http://msdn.microsoft.com/en-us/libr...bd(VS.80).aspx http://msdn.microsoft.com/en-us/library/ee342218.aspx http://code.msdn.microsoft.com/ http://support.microsoft.com/kb/316384 http://support.microsoft.com/kb/302084
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Programming Book Page Format Sample | SQLUSA | Word | 12 | 08-03-2012 02:15 AM |
Outlook programming | waldux | Outlook | 0 | 01-10-2012 12:47 PM |
Content Controls Form Programming | beachdog | Word VBA | 4 | 09-20-2011 10:26 AM |
outlook programming add Junk e-mail option to menu bar | chriskaza81 | Outlook | 0 | 11-25-2010 03:58 AM |
Programming based on an enter key event | edayers315 | Word VBA | 0 | 06-11-2010 09:57 AM |