Solved

Word automation using vb.net 2010 and MS office 2010

Posted on 2013-01-18
8
747 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 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

772 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