zxj_76 发表于 2004-4-15 09:16:00

[求助] 用DAO连接EXCEL为什么经常丢数据(附图)?

程序代码及跟踪结果:
http://www.5ivb.net/club/UploadFile/2004414163637byUID3191.jpg
EXCEL表实际内容:
http://www.5ivb.net/club/UploadFile/2004414163647byUID3191.jpg
问题:表中第二行(即数据库中的MOVEFIRST)有好几个数字没有被读出,另外501的第四列550*300没有被出,512的第10列的“3”没有被读出,等等,请问各位高手是为什么,程序代码在上图中。

gamelemon 发表于 2004-8-23 15:07:00

我连怎么样连接EXCEL都不会,请楼主先教教我基本的东西

自由弧 发表于 2004-9-7 20:14:00

另外501的第四列550*300没有被出
可能因为那个"*"

style6301 发表于 2007-11-12 11:15:00


请问怎么连接Excel,怎么将属性块中的属性写入Excel

兰州人 发表于 2007-11-16 23:08:00

Sub Example_IntersectWith()
   Dim xlApp As Object    ' This Line ,Not set Excel , run Excel
   'Dim xlsheet As Object
   
   ' 发生错误时跳到下一个语句继续执行
   On
                Error
                Resume
                Next
   ' 连接Excel应用程序
   Set xlApp =
                GetObject(, "Excel.Application")
   
   If Err.Number0 Then
         Set xlApp = CreateObject("Excel.Application")
         xlApp.Visible
                = True
         xlApp.Workbooks.Add
   End If
   ' 返回当前活动的工作表
   'Set xlsheet = xlApp.ActiveSheet
   Set xlSheet = xlApp.sheets(1)
   ' This example creates a line and circle and finds the points at
   ' which they intersect.
   Dim oBject As
                AcadEntity, oBject1 As
                AcadEntity
   Dim ii As Integer, jj As Integer
   Dim Ppt As Variant
   nn = 1
   For ii = 0 To ThisDrawing.ModelSpace.Count - 1      
       Set oBject =
                ThisDrawing.ModelSpace.Item(ii)      
       For jj = 0 To ThisDrawing.ModelSpace.Count - 1
         Set oBject1 =
                ThisDrawing.ModelSpace.Item(jj)      
         Ppt = oBject1.IntersectWith(oBject, acExtendOtherEntity)
         xlSheet.Cells(nn, 1).Value
                = Format(Ppt(0), "0.0")
         xlSheet.Cells(nn, 2).Value
                = Format(Ppt(1), "0.0")
         xlSheet.Cells(nn, 3).Value
                = Ppt(2)
         Debug.Print Ppt(0), Ppt(1), Ppt(2)
         Debug.Print nn, oBject.Handle, oBject1.Handle
         xlSheet.Cells(nn, 4).Value
                = nn
         nn = nn + 1
       Next jj
   Next ii   
End Sub
直接用调用Excel
页: [1]
查看完整版本: [求助] 用DAO连接EXCEL为什么经常丢数据(附图)?