Dim wordapp As New Word.Application
'double click the filename
wordapp.Visible = True
Call wordapp.Documents.Open("filename")
'if quit
Set wordapp = Nothing

解决方案 »

  1.   

    用可以用shell("word.exe" &" " & filename)直接打开WORD。
      

  2.   

    有时候,我们会忘记简单的方法:
    ' Notepad:
    Result = Shell("start.exe notepad", vbHide) 
    ' E-mail:
    nResult = Shell("start.exe mailto:[email protected]", vbHide)
    ' Internet:
    nResult = Shell("start.exe http://vbtt.yeah.net", vbHide)
    ' Word
    nResult = Shell("start.exe myfile.doc", vbHide)
    ' Picture Viewer
    nResult = Shell("start.exe myfile.jpg", vbHide)
      

  3.   

    按照第一位老兄的做法,为什么vb会告诉我用户定义类型未定义,且显示是"wordapp As New Word.Application"有问题。
      

  4.   

    Project->References: check the "Microsoft Word 9.0 Object Library"
      

  5.   

    多谢上面几位仁兄的帮助,可是小弟在操作中又碰到了一个问题,请指教。
    我是想双击记录才打开文件,可是按照第一位的方法,鼠标点一下就打开文件了。
    另外,我想点不同的记录打开不同的文件,比如点“1”就打开“1.doc”点“2”就打开“2.doc”.......,请将代码写详细点,小弟实在是个菜鸟。我会多多加分的。
      

  6.   

    使用Dblclick事件。
    Dim wordapp As New Word.Application
    private sub command1_dblclick()
    'double click the filename
    wordapp.Visible = True
    Call wordapp.Documents.Open("filename")
      ...
    end sub
    sub form_Unload()
    'if quit
    'do the things 
    'this will quit
    Set wordapp = Nothing 
    end sub