明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 908|回复: 2

VB6 封装出错,不会修正

[复制链接]
发表于 2020-8-8 17:02:06 | 显示全部楼层 |阅读模式
用VB6封装一下程序,Dim objText As AcadText——提示“用户定义类型未定义”,请高手帮忙看看怎么改。
封装是为了使用方便。

以下是源代码:

Private Sub Command1_Click()

Dim objExcelApp As Object, objSheet As Object
Dim objCADApp As Object, objDoc As Object
Dim pointName As String, pointX As Double, pointY As Double
Dim txtP(2) As Double, txtH As Double, txtM As Double
Dim objText As AcadText
Dim myr As Integer


Set objExcelApp = GetObject(, "Excel.Application") '获得系统中运行的EXCEL
Set objSheet = objExcelApp.ActiveWorkbook.ActiveSheet '返回当前活动工作表
Set objCADApp = GetObject(, "AutoCAD.Application") '获得系统中运行的cad
Set objDoc = objCADApp.ActiveDocument '返回当前活动

txtH = 50 '文字高度

For i = 1 To 10000
    pointName = objSheet.cells(i, 1) '读取坐标点名(A列)
    pointX = objSheet.cells(i, 2) '读取坐标点经度(b列)
    pointY = objSheet.cells(i, 3) '读取坐标点纬度(c列)
    txtM = objSheet.cells(i, 4)
    txtP(0) = pointX
    txtP(1) = pointY


  Set objText = objDoc.ModelSpace.AddText(pointName, txtP, txtH)
  objText.Rotate objText.InsertionPoint, txtM / 180 * 3.14159265
  objText.ScaleFactor = 0.5

Next

End Sub

发表于 2020-8-8 20:32:33 | 显示全部楼层
Dim objText As Object
 楼主| 发表于 2020-8-9 09:30:40 | 显示全部楼层
yshf 发表于 2020-8-8 20:32
Dim objText As Object

感谢,好用了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 04:46 , Processed in 0.161717 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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