Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3942846
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:42:42+00:00 2026-05-20T00:42:42+00:00

Foreword: I want to allow users to define high quality document templates and then

  • 0

Foreword: I want to allow users to define high quality document templates and then inject there data from our information system and print the result. I think MS Word is a great starting point, because this work is aimed to business letters etc., not data reports.

Question: Is it possible to add a custom field provider to MS Word?

I don’t have English MS Word, so I must try to describe what I mean in a few sentences. Normally we can insert “fields” like author name, current date etc. These fields work seamlessly. We can switch view of fileds between data and definition. Definion of author field looks like this: { AUTHOR \\* MERGEFORMAT }.

Now I want to inject external data into documents and let user specify where to put them. A user should define a document template and mark spots where external data should be injected. Since Word users generally aren’t IT experts, the easiest way for them is to use some macros or “insert field” option to do it. So I want to define my own set of fields and connect Word to my custom field and data provider. How to do it? I am unable to find any documentation on this.

I think this approach is better than using sql database connection or something like that, because I want to let the external source define list of known fields and their values, not the docx document itself. Also, data source won’t actually be an sql database.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T00:42:43+00:00Added an answer on May 20, 2026 at 12:42 am

    Yes you can do this by using Custom Document Properties as placeholders and then use some VBA code to set those properties to whatever you want. You can get the data via ODBC or from an Excel spreadsheet or from a text file.

    First of all, experiment manually by going into File, Properties and creating some custom properties. Give them a value and then, in the document, insert some DocProperty fields. If you can’t find DocProperty in your language version of Word then look through a list of the fields like Author etc. Since field names are visible to end users they might have been translated.

    Then in order to complete your document template, create a VBA function that uses SetProperty. Read this article for more details. It is up to you whether the VBA is triggered by opening the file or whether you add a menu item to do that.

    No need for special controls or any commercial add-ons. I’m going to add a VBA tag to your question since this is really a VBA programming question. In fact, this has been possible since Word for Windows 1.0.

    Using SetProperty in VBA is a bit more complex now. I got the following snippet of code from this forum posting.

    object docProps = wdDoc.CustomDocumentProperties;
    Type docPropsType = docProps.GetType();
    object Prop = docPropsType.InvokeMember(“Item”,
    BindingFlags.Default |
    BindingFlags.GetProperty,
    null, docProps,
    new object[] {propName} );
    Type PropType = Prop.GetType();
    PropType.InvokeMember(“Item”,
    BindingFlags.Default |
    BindingFlags.SetProperty,
    null, docProps,
    new object[] {propName,propValue} );

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: Updated code. Now works well enough. Foreword. I am an OpenGL newb tasked
I would like to know if maybe there are some good solutions to handling
foreword: I have a component, lets call it IView. This component is implemented by
Foreword: Although I don't think it's exactly a duplicate, feel free to close if
Foreword: I am not trying to write an alternative either to Subversion or to
Foreword tl;wr: This is a discussion. I am aware that this question is more
Good morning, afternoon or night, Foreword: The code below does nothing really useful. It
Foreword Before asking a question that probably will pretend to downvoting (as it seems
Foreword: Okay I've used APIs in the past such as TwitterAPI but I always
Just a foreword: I'm not exactly clear on how a RNG actually works. If

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.