Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-06-2013, 12:50 PM
vmsobral vmsobral is offline Using programming with Word Templates Windows 7 64bit Using programming with Word Templates Office 2010 64bit
Novice
Using programming with Word Templates
 
Join Date: Feb 2013
Posts: 2
vmsobral is on a distinguished road
Default 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!
Reply With Quote
  #2  
Old 02-06-2013, 01:27 PM
OTPM OTPM is offline Using programming with Word Templates Windows 7 32bit Using programming with Word Templates Office 2010 32bit
Expert
 
Join Date: Apr 2011
Location: West Midlands
Posts: 981
OTPM is on a distinguished road
Default

Hi
Suggest you post this in the Word VBA Section.
Tony
Reply With Quote
  #3  
Old 02-06-2013, 02:13 PM
macropod's Avatar
macropod macropod is offline Using programming with Word Templates Windows 7 64bit Using programming with Word Templates Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by OTPM View Post
Suggest you post this in the Word VBA Section.
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:
Should I use merge fields, content control or other feature, and later edit those with C#?
without knowing what you're trying to accomplish, it's rather hard to say. Some customisations might best be implemented via custom Quick Parts, for example.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 02-07-2013, 08:40 AM
vmsobral vmsobral is offline Using programming with Word Templates Windows 7 64bit Using programming with Word Templates Office 2010 64bit
Novice
Using programming with Word Templates
 
Join Date: Feb 2013
Posts: 2
vmsobral is on a distinguished road
Default

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!
Reply With Quote
  #5  
Old 02-07-2013, 01:45 PM
macropod's Avatar
macropod macropod is offline Using programming with Word Templates Windows 7 64bit Using programming with Word Templates Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply



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

Other Forums: Access Forums

All times are GMT -7. The time now is 09:43 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft