?
Solved

open existing word document, add something to bottom, save and close

Posted on 2009-07-14
9
Medium Priority
?
388 Views
Last Modified: 2013-11-18
I have spent a great deal of the day searching EE and the web trying to avoid asking this question.  I have a database that houses links to the location of word documents saved on a fileserver.  The program, in .asp allows the user to click the link and open the document.  These are patient dictations.  Ideally, i would like a button that a doctor can use to press that somehow appends to the bottom of that note the fact that they have approved and electronically signed off on that note.  Yes, it is way too much trouble for them to simply click the link, type it at the bottom and then hit save...remember they are doctors not advanced preschoolers.  Thanks in advance.  
0
Comment
Question by:NUdovich2
[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
  • 6
  • 3
9 Comments
 
LVL 11

Accepted Solution

by:
tobzzz earned 2000 total points
ID: 24854645
Perhaps you can try this, where you use a command to read the document, then replace a certain line? It would mean that "Not yet approved" must be in all the docs already though. You may be able to use a similar principle though. Check out the "createobject" vbscript feature:
http://msdn.microsoft.com/en-us/library/dcw63t7z(VS.85).aspx

Const ForReading = 1 : Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\myWordFile.doc", ForReading)
strText = objFile.ReadAll
objFile.Close
 
strNewText = Replace(strText, "Not yet approved","Approved")
Set objFile = objFSO.OpenTextFile("c:\myWordFile.doc", ForWriting)
objFile.WriteLine strNewText
objFile.Close

Open in new window

0
 

Author Comment

by:NUdovich2
ID: 24855439
is this applicable to classic .asp?  Looks like this is asp.net, which unfortunately I am not using.  
0
 

Author Comment

by:NUdovich2
ID: 24855602
I take that back it worked like a charm, but only worked server side.  It wasnt working because I hadn't created the test.doc on the server side.  However, what if the document is on a file server that does not host the IIS?  Can I reference that?  I hopefully will figure that out before you can answer but really great simple, slick solution.  Thanks.
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!

 

Author Comment

by:NUdovich2
ID: 24856155
well, this works but only serverside, what can I do to reference the fileserver from the local machine.  Thanks!

<%@ Language="VBScript" %>
<%
Dim objFSO, objFile, strText, strNewText, strRemotePath, foo, strp
strRemotePath="\\Nas\Users\Dictations\Dictations\Louise.doc"
foo=strRemotePath
Const ForReading = 1 : Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(foo, ForReading)
strText = objFile.ReadAll
objFile.Close
 
strNewText = Replace(strText, "Not yet approved","Approved")
Set objFile = objFSO.OpenTextFile(foo, ForWriting)
objFile.WriteLine strNewText
objFile.Close
%>

Open in new window

0
 
LVL 11

Expert Comment

by:tobzzz
ID: 24859131
If it's all done on a local machine, then either IIS must be on that machine (you need IIS to run ASP!!!) or you must be on an internet page or extranet/intranet that supports this.

I don't know your setup so it's hard to say, but I saw your question was for ASP and VB so hoped my solution would work with Word docs, I'm pleased it did. I hope you can work out how to make it work on your setup.

0
 

Author Comment

by:NUdovich2
ID: 24859369
no need to get all exclamation-ey on me.  I am well aware one needs IIS to run asp.  My point was that the document as referenced in your code needed to be on the server running IIS.  I was trying to reference documents NOT on the IIS machine.  Now that I have figured that out, the code seems to corrupt the word document... I get it, it may not be the code it may be some other issue.  
0
 
LVL 11

Expert Comment

by:tobzzz
ID: 24859697
Whoops, I really didn't intend to upset you there, many apologies, it's just my style of writing, we're all here to help each other, I hope I wasn't condescending - I am by no means an expert! Sorry NUdovich.

I suppose if they're not on the same server it wouldn't work, because it is (as you say) serverside code. It sounds ilke a difficult project. If you're able to do it but corrupt the doc, you are getting close.
0
 

Author Comment

by:NUdovich2
ID: 24860400
no worries, the code is definitely executing and finding the specific document.  Just afterwords, the document is all crazy charaters, can't even be opened in word.  I want to leave the question open for now just to see if anyone can add to this discussion.  For note, IIS runs on both the machine that runs the site as well as the fileserver.  The fileserver IIS references the webhost server, in case that is relevant..I am by no means an expert either.  
0
 

Author Comment

by:NUdovich2
ID: 24860531
OK, for those following the thread the issue isnt the code or the location...the variable that I removed from the system was that of the document itself; meaning, the documents I was using were real documents.  Instead I created a new document that was effectively blank; doing this made it work w/o screwing up the document.  Worthy of additional investigation but the original question has been answered...case closed.  
0

Featured Post

Industry Leaders: 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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

801 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