|
支持版版,来一个VB的东东,我的一个文件管理程序中提取出来的(excel,word,autocad,pdf,CorelDraw)。
Private Sub File1_Click()
On Error Resume Next
If Right(File1.FileName, 3) = "xls" Then
Set ExlApp = CreateObject("excel.application")
ExlApp.Visible = True '设置属性为可见
ExlApp.workbooks.Open (Dir1.Path & "\" & File1.FileName)
End If
If Right(File1.FileName, 3) = "doc" Then
Dim word As Object
Set word = CreateObject("word.application")
word.Visible = True '设置属性为可见
word.documents.Open (Dir1.Path & "\" & File1.FileName)
End If
If Right(File1.FileName, 3) = "dwg" Then
Dim acad As Object
Set acad = CreateObject("autocad.application")
acad.Visible = True '设置属性为可见
acad.documents.Open (Dir1.Path & "\" & File1.FileName)
End If
If Right(File1.FileName, 3) = "pdf" Then
Dim pa As String, pat1 As String, pat2 As String
pat1 = "C:\Program Files\Adobe\Acrobat 6.0\Acrobat\Acrobat.exe " ', vbNormalFocus ' NOTE SPACE after exe
pat2 = Dir1.Path & "\" & File1.FileName
pa = pat1 & pat2
Shell pa, vbNormalFocus
pdfapp.documents.Open (Dir1.Path & "\" & File1.FileName)
End If
If Right(File1.FileName, 3) = "cdr" Then
Dim cdrapp As Object
Set cdrapp = CreateObject("coreldraw.application")
cdrapp.Visible = True '设置属性为可见
cdrapp.documents.Open (Dir1.Path & "\" & File1.FileName)
End If
End Sub
这里用case会更简洁,但我为了扩展其他文件后缀用的if 语句。
要补充说明的是:要在filelistbox的属性pattern中限制文件格式
*xls*;*doc*;*dwg*;*pdf*;*cdr* |
|