Solved

Using merge option of word document from

Posted on 2004-08-03
3
148 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
Comment Utility
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
Comment Utility
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
Comment Utility
Imports Microsoft.Office.Interop
Imports Word

Name is the bookmark only
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now