Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Word automation using vb.net 2010 and MS office 2010

Posted on 2013-01-18
8
Medium Priority
?
770 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Independent Software Vendors: 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!

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

916 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