Solved

Using merge option of word document from

Posted on 2004-08-03
3
153 Views
Last Modified: 2010-04-23
Hi,
I have a word document template (let's say in C drive).
The document has few merge fields let's say <<FirstName>> and <<LastName>>.
Now, I need to create a dll/vb.net code where in when I run the application must replace the fields <<FirstName>> and <<LastName>> with the values passed and ask me to open/Close/save the document.
I am looking at similar feature to merge, replace text.
However, my original template must still be the same.

Regards,
0
Comment
Question by:kkuchana
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
gova earned 125 total points
ID: 11724734
As an alternative you can try this code which uses the bookmarks
On a button click event write this code.

 Dim word_server As Word.Application
        Dim thisDoc As Word.Document
        word_server = New Word.Application()

        word_server.Documents.Open("C:\Original.doc")
        thisDoc = word_server.ActiveDocument
        word_server.Selection.GoTo( _
       What:=Word.WdGoToItem.wdGoToBookmark, _
       Name:="Name")
        word_server.Selection.TypeText( _
            Text:="some value")
        word_server.Visible = True
0
 

Author Comment

by:kkuchana
ID: 11724756
How about importing the namespaces
and hopefully Name:="Name" where the later "Name" is the BookMark
How about saving the document?

0
 
LVL 5

Expert Comment

by:gova
ID: 11724772
Imports Microsoft.Office.Interop
Imports Word

Name is the bookmark only
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

685 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