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

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.  
NUdovich2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tobzzzCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NUdovich2Author Commented:
is this applicable to classic .asp?  Looks like this is asp.net, which unfortunately I am not using.  
0
NUdovich2Author Commented:
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
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

NUdovich2Author Commented:
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
tobzzzCommented:
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
NUdovich2Author Commented:
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
tobzzzCommented:
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
NUdovich2Author Commented:
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
NUdovich2Author Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Components

From novice to tech pro — start learning today.