Link to home
Start Free TrialLog in
Avatar of Member_2_1242703
Member_2_1242703

asked on

Opening a textfile in Wordpad using ActiveX

How do I open a particular text file in wordpad using ActiveX?
ASKER CERTIFIED SOLUTION
Avatar of b0lsc0tt
b0lsc0tt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Member_2_1242703
Member_2_1242703

ASKER

Scott,

Thanks. That script works great but it opens my file in the default text editor which in my case (and most of my users) is Notepad. I need to force this file to open in Wordpad.

Thanks
<HTML>
<HEAD>
<TITLE>
test
</TITLE>
 
<script type="text/javascript">
var shell = new ActiveXObject("Wscript.Shell");
shell.run("C:\\test.txt");
</script>
 
</HEAD>
<BODY>
 
</BODY>
</HTML>

Open in new window

Got it!
One more question...
How do you format a file on a network drive?
Say my file is at \\myserver\myfolder\myfile.txt

<HTML>
<HEAD>
<TITLE>
test
</TITLE>
 
<script type="text/javascript">
var shell = new ActiveXObject("Wscript.Shell");
shell.run("WORDPAD C:\\Reports\\test.txt");
</script>
 
</HEAD>
<BODY>
 
</BODY>
</HTML>

Open in new window

I'm glad you noticed the fact you left out wordpad, the command. :)
I am not sure a UNC path will work, or at least for all operating systems.  If it doesn't you will need to map the drive.  Having said that though the slashes in the normal UNC path above would need to be escaped so you would use ...
shell.Run("wordpad \\\\myserver\\myfolder\\myfile.txt");
Let me know if you have any more questions about opening a text file in Wordpad.
bol

 
Most of the users will have a drive mapped to this location, I just wanted to use the UNC in the event that someones drive mapping gets dropped, etc. Thanks again for all your help!

Your welcome!  I'm glad I could help.  Thanks for the grade, the points and the fun question.
bol