Solved

Word automation using vb.net 2010 and MS office 2010

Posted on 2013-01-18
8
753 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 70

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 70

Expert Comment

by:Éric Moreau
ID: 38795290
looks like no printer is available. you are running this from IIS? on the server?
0
 

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 70

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 70

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

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

763 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