大虾圣诞快乐,VB提示错误"用户定义类型未定义" ,为什么?谢谢
Private Sub Command1_Click()Dim A As Object
Dim B As Object
Dim c As Object
Set A = CreateObject("excel.application")
A.Visible = True
Set B = A.Workbooks.Open("D:\必要的数据\JOB\2009\DB\hard\新建 Microsoft Excel 工作表.xls")
Set c = B.worksheets(1)
c.Activate
Dim myrange As c.Range
With c
Set myrange = .Range("A1:A2")
With myrange
.MergeCells = True '合并表格中指定的单元格
.Value = "起讫桩号"
End With
End With
End Sub
--------------------编程问答-------------------- 类型c.Range 不存在,删除Dim myrange As c.Range 一句 --------------------编程问答-------------------- 隐藏了。。。 --------------------编程问答-------------------- '上面 工程 先引用 Microsoft Excel 9.0 Object Library --------------------编程问答-------------------- '不需引用
Option Explicit
Dim vbexcel11 As Object
Dim vbbook As Object
Dim Rownum%, str1$, str2$, str3$, str4$, len1%, len2%, len3%, CC$
Private Sub Form_Load()
Set vbexcel11 = CreateObject("Excel.Application") '创建excel对象
vbexcel11.Visible = True '对象可见
Set vbbook = vbexcel11.Workbooks.Open("c:\tt.xls") '打开文件
Me.Caption = "Excell 读取"
End Sub
--------------------编程问答-------------------- 错在哪个位置? --------------------编程问答-------------------- Dim myrange As Object
--------------------编程问答-------------------- 全编译运行一下就知道了 --------------------编程问答-------------------- 这个好象不对吧Dim myrange As c.Range --------------------编程问答-------------------- Dim myrange As object --------------------编程问答--------------------
Private Sub Command1_Click()
Dim A As Object
Dim B As Object
Dim C As Object
Set A = CreateObject("excel.application")
A.Visible = True
Set B = A.Workbooks.Open("D:\必要的数据\JOB\2009\DB\hard\新建 Microsoft Excel 工作表.xls")
Set C = B.worksheets(1)
C.Activate
With C
.Range("A1:A2").MergeCells = True '合并表格中指定的单元格
.Range("A1:A2").Value = "起讫桩号"
End With
End Sub
补充:VB , VBA