Solved

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

Posted on 2009-07-14
9
382 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
  • 6
  • 3
9 Comments
 
LVL 11

Accepted Solution

by:
tobzzz earned 500 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
 

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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now