vb引用excel后仍提示用户定义类型未定义

代码如下PrivateSubCommand1_Click()Dimz1,z2,z5AsIntegerDimi,m,n,a,P,n1,n6,n16,TAsDoublei=V... 代码如下
Private Sub Command1_Click()
Dim z1, z2, z5 As Integer
Dim i, m, n, a, P, n1, n6, n16, T As Double
i = Val(Text2.Text)
P = Val(Text1.Text)
n = Val(Text4.Text)
m = Val(Text3.Text)
Dim k As Integer
Dim xlapp As Excel.Applocation
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim FileName1, SheetName As String
FileName1 = "D:\data.xls"
SheetName = "sheet1"
Set xlapp = CreateObject("Excel.Application")
Set xlBook = xlapp.Workbooks.open(FileName1)
xlapp.Visible = ture
Set xlSheet = xlBook.Worksheets(SheetName)
For z1 = 17 To 100
For z2 = Int(z1 * 1.5) To 150
z5 = (i - 1) * z1 / z2
n1 = (z5 / (z5 - 1) - 1) * (z5 / (z5 - 1) - 0.998 + z2 * z5 * 0.992 / (z1 * (z5 - 1)))
n6 = (z5 / (z5 - 1) - 0.998) * ((z5 / (z5 - 1) - 1 + z2 * z5 / (z1 * (z5 - 1))))
n16 = n1 / n6
n3 = n16 * 0.99 ^ 3
T = 9550000 * P * n3 / n
a = m * (z1 + z2) / 2
If z5 Mod 2 = 0 Then
If 0.51 * (T ^ (1 / 3)) <= a And a <= 0.65 * (T ^ (1 / 3)) Then
k = k + 1
xlSheet.Cells(k, 1) = z1
xlSheet.Cells(k, 2) = z2
xlSheet.Cells(k, 3) = z5
xlSheet.Cells(k, 4) = n3
xlSheet.Cells(k, 5) = T
xlSheet.Cells(k, 6) = 1 + (z2 / z1) * z5
End If
End If
Next z2
Next z1
xlBook.SaveAs FileName:=FileName1
xlBook.Close
xlapp.Quit
Set slApp = Nothing
End Sub
展开
 我来答
寒信HK
2017-04-28 · TA获得超过1876个赞
知道大有可为答主
回答量:1326
采纳率:92%
帮助的人:393万
展开全部
Dim xlapp As Excel.Applocation 这句拼写错了,应该是Excel.Application
追问

我改过来了,但是还是出错

我是vb6.0 office2017,这个有影响么

追答
不好意思,没用过2017,不知道有没有影响。但是修改后代码在office2003是可以通过的。
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式