明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2665|回复: 2

高手们教教我!!

[复制链接]
发表于 2005-5-25 22:18:00 | 显示全部楼层 |阅读模式
代码如下: Dim inblock As String
Dim layer As String
Dim direc As String
Dim blockname As String
Dim xsca As Integer
Dim ysca As Integer
Dim zsca As Integer
Dim xlas As Integer
Dim ylas As Integer
Dim zlas As Integer Dim excelapp As New Excel.Application
excelapp.Workbooks.Open "d:\cad.xls", , ReadOnly
With excelapp.ActiveWorkbook.Worksheets("Sheet1")
layer = .Range("f2")
direc = .Range("g2")
blockname = .Range("a2")
xsca = .Rang("h2")
ysca = .Range("i2")
zsca = .Range("j2")
xlas = .Range("k2")
ylas = .Range("l2")
zlas = .Range("m2") TextBox1.Text = blockname
TextBox3.Text = layer
TextBox4.Text = direc
TextBox5.Text = xsca
TextBox6.Text = ysca
TextBox7.Text = zsca
TextBox8.Text = xlas
TextBox9.Text = ylas
TextBox10.Text = zlas End With
调试时说 “With excelapp.ActiveWorkbook.Worksheets("Sheet1")” 运行时错误9 下标越界 不解~~~~~教教!!
发表于 2005-5-26 16:41:00 | 显示全部楼层
xsca = .Rang("h2")应该是xsca = .[I]Range[/I]("h2")吧?


而且这段代码我试了,最有可能的原因是


With excelapp.ActiveWorkbook.Worksheets("Sheet1")语句中你指定的[I]"Sheet1"工作表在"cad.xls"工作薄中是不存在[/I]的,如果该工作表[I]不存在,就会产生"运行时错误9"[/I]
 楼主| 发表于 2005-5-26 20:07:00 | 显示全部楼层
跪谢!!!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-12-23 14:15 , Processed in 0.171528 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表