' For i = 1 To Application.VBE.ActiveVBProject.References.Count
' If Application.VBE.VBProject.References(i).IsBroken Then
' Application.VBE.ActiveVBProject.References.Remove _
' Application.VBE.ActiveVBProject.References(i)
' Exit For
' End If
' Next i
' Application.VBE.ActiveVBProject.References.
If SysCmd(acSysCmdAccessVer) = "9.0" Then
Application.VBE.ActiveVBProject.References.AddFromFile _
"d:\Program\office2k\office\EXCEL9.OLB"
Else
Application.VBE.ActiveVBProject.References.AddFromFile _
"d:\Program\office2k\office\EXCEL10.olb"
End If
End Sub作者: wang1950317 时间: 2006-7-28 23:00
谢谢5楼大师,您的代码是office2000,如何使office2000的10.0或office2003的Excel 11.0都能自动转换, Else下面的那句代码该怎样改动?谢谢!
作者: nmfx1122 时间: 2006-7-28 23:20
实现access 自动引用 Excel
Select Case SysCmd(acSysCmdAccessVer)
Case "9.0"
Debug.Print "当然Access版本:" & SysCmd(acSysCmdAccessVer)
Application.VBE.ActiveVBProject.References.AddFromFile _
"d:\Program\office2k\office\EXCEL9.OLB"
Case "10.0"
Application.VBE.ActiveVBProject.References.AddFromFile _
"d:\Program\office2k\office\EXCEL10.olb"
Case Else
Debug.Print "未知版本Access"
End Select
End Sub作者: wang1950317 时间: 2006-7-29 23:50 谢谢nmfx1122大侠:是放在模块中吗?我试过了,好像不起作用?是不是我的那儿设置有问题?d:\Program\office2k\office\EXCEL10.olb中,如果我的office装在C盘是不是要改成C:\ ?作者: nmfx1122 时间: 2006-7-30 00:26
路径要自己改。