tags:

views:

310

answers:

2

I know how to create a text file using VBScript which is shown below:

Dim a As New FileSystemObject
Set Text = a.CreateTextFile("C:\Folder\test.txt")

Now I want some script so that my this test.txt file just opens in front of my monitor. Because I know that when we make an Excel file, we just use

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True

When used the Excel sheet is created and just opens up in front of us. In a similar way I had tried for text file but it's not at all working.

What would be a solution?

+4  A: 

You can use WScript.Shell's Run method to launch documents in their associated editor:

Dim a As New FileSystemObject
Set Text = a.CreateTextFile("C:\Folder\test.txt")

Dim wsh
Set wsh = WScript.CreateObject("WScript.Shell")

wsh.Run "C:\Folder\test.txt"
Kim Gräsman
Kim,Thanks a lot and now its working just fine
Maddy - you're welcome! Could you accept the answer?
Kim Gräsman
How do u accept answers kim??
There should be a little check-mark under the voting arrows to the left of this answer, just click that :)
Kim Gräsman
Kim,its done.Can u just suggest me some link where i could learn vbscripts with test complete tool as i started working on this some weeks back.??
Nope, sorry, I don't know anything about Test Complete.
Kim Gräsman
Kim,anything related to advanced vbscripting e books??
It's been years since I did any VBScript, and learned all of it through experimentation and through online samples, so unfortunately I don't have any more references for you. Good luck!
Kim Gräsman
+1  A: 

If you want to open your file using an another editor other than the one associated do:

Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("notepad c:\path\file.txt")
ghostdog74
@ghostdog,Thanks a lot