Solved

Word automation using vb.net 2010 and MS office 2010

Posted on 2013-01-18
8
743 Views
Last Modified: 2013-01-22
I am working on word Templets in vb.net.
All i need to do is open the word document and replace some some text in word document and print it.

Here is the sample templet:


Applicant Name:<Name>
MRN:<MRN>
Effective Date:<Date>

Thank you for applying. We have reviewed the information you gave us. You are not eligible . This is because: .....some text..........

I need to replace <NAME>,<MRN> and <DATE> from the vb.net application and the print the word document.


Thanks for your help.
0
Comment
Question by:Nettodotnet
  • 4
  • 3
8 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 38794491
0
 

Author Comment

by:Nettodotnet
ID: 38794685
Below is the code i am using.

When i deployed into test server its not printing but iam reciving below dialog box.
Dialog box: Save This file as.
"Save this file as *.xps."

I am running this from IIS Browser.


CODE:

        Dim oa As word.Application
        Dim od As word.Document
        oa = New word.Application()
        Dim orgfilename = ""
       

        Try
                    orgfilename = Server.MapPath("~/Templets/6PresumptiveEligibility.doc")

                    od = oa.Documents.Open(orgfilename)
                    od.Activate()
                    od.Content.Find.Execute(FindText:="CurrDate", ReplaceWith:=Date.UtcNow())
                    od.Content.Find.Execute(FindText:="CurrMRN", ReplaceWith:=vMRN)
                    od.Content.Find.Execute(FindText:="CurrFullName", ReplaceWith:=vName)
                    Threading.Thread.Sleep(10000)
                    od.PrintPreview()
                    od.PrintOut()
                    Threading.Thread.Sleep(10000)
                    oa.Quit(SaveChanges:=False)
                    oa = Nothing
                    od = Nothing
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38795076
You want to print it to client printer or server printer? You will have to send the file to client so user can print it. To print on server, you would need to set the printer as its currently being set as XPS file printer.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 38795290
looks like no printer is available. you are running this from IIS? on the server?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Nettodotnet
ID: 38795526
My need is to print from clinet.


This is working fine on My local box, But as soon as i deployed into test server, the printer is not working. Then i log into test server and try to run from IIS.But on server there is no printer is set up.

Do i need to setup Printer on the server?
0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 38796438
you need to return the document to the user and he will print it. you cannot print on a client computer from a server
0
 

Author Comment

by:Nettodotnet
ID: 38796814
emoreau,

can you explain more ..what i need to be done for this. I see in your message "return the document to th user and he will print it"..???
what does it ment?
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 38797053
check the comment of  Robert Hutch @ 6:47 15 Feb '12 from http://www.codeproject.com/Articles/3959/Microsoft-Word-Documents-from-ASP-NET
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

760 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

17 Experts available now in Live!

Get 1:1 Help Now