以下是引用ssq1109在2007-1-7 11:42:49的发言:在VB6中进行适当引用并写出下列语句后能处理WORD文档: Dim wdApp As Word.Application Dim aDoc As Document Set wdApp = New Word.Application 但前提是机器上已安装了WORD,所以我希望: 1. 在代码中加进判断该机上是否已安装了WORD的语句(WORD的版本及安装在哪个目录下不限),如未安装,告诉用户:“本机上未安装WORD,请先安装后再运行本程序!”; 2. 如该机上已安装了WORD,要求在代码中接着判断WORD是否已启动,如已启动,告诉用户:“WORD已启动,请先退出后再运行本程序!”。 以下代码供参考: '* +++++++++++++++++++++++++++++ '* Created By SHOUROU@ExcelHome 2007-1-14 7:51:12 '仅测试于System: Windows NT Word: 11.0 Language: 2052 '№ 0129^The Code CopyIn [ThisDocument-ThisDocument]^' '* ----------------------------- Option Explicit Sub GetWdApp() Dim wdApp As Object On Error Resume Next Set wdApp = GetObject(, "Word.Application") If Err.Number <> 0 Then Err.Clear Set wdApp = CreateObject("Word.Application") If Err.Number <> 0 Then Err.Clear MsgBox "本机上未安装WORD,请先安装后再运行本程序!", vbInformation Else MsgBox "您的电脑中已安装Word程序!", vbInformation wdApp.Quit End If Else MsgBox "WORD已启动,请先退出后再运行本程序!", vbInformation End If End Sub '----------------------
|