Solved

Using merge option of word document from

Posted on 2004-08-03
3
152 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

790 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