如何查看刚刚使用 VBScript 创建的文本文件? [英] How can I view a text file I've just created using VBScript?

查看:13
本文介绍了如何查看刚刚使用 VBScript 创建的文本文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何使用 VBScript 创建文本文件,如下所示:>

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")

现在我想要一些脚本,这样我的这个 test.txt 文件就可以在我的显示器前打开.因为我知道我们在制作Excel文件的时候,只要使用

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

使用时,Excel 工作表被创建并在我们面前打开.以类似的方式,我尝试过文本文件,但根本不起作用.

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.

什么是解决方案?

推荐答案

您可以使用 WScript.Shell 的 Run 方法在相关编辑器中启动文档:

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"

这篇关于如何查看刚刚使用 VBScript 创建的文本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆