Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Word automation using vb.net 2010 and MS office 2010

Posted on 2013-01-18
8
Medium Priority
?
764 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
Amazon Web Services EC2 Cheat Sheet

AWS EC2 is a core part of AWS’s cloud platform, allowing users to spin up virtual machines for a variety of tasks; however, EC2’s offerings can be overwhelming. Learn the basics with our new AWS cheat sheet – this time on EC2!

 
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 2000 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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

721 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