|
发表于 2004-12-23 17:59:00
|
显示全部楼层
现在可以打开文件了,但是还是有一个问题啊,我修改后的代码如下:
Dim acadapp As Object '建立Application对象
Dim acaddoc As Object '建立Document对象
On Error Resume Next
Set acadapp = GetObject(, "autocad.application.14") '若AutoCad已启动 , 则直接得到
If Err Then
Err.Clear
Set acadapp = CreateObject("autocad.application.14") '若AutoCad未启动,则运行它
If Err Then
MsgBox Err.Description
Exit Function
End If
End If
MsgBox "Now running " + acadapp.Name + " version " + acadapp.Version
Set acaddoc = acadapp.ActiveDocument '设acaddocs为当前图形文件
Dim dwgname As String
dwgname = "C:\temp\temp.dwg"
If Dir(dwgname) "" Then
acaddoc.Open (dwgname) '打开一个CAD文件
MsgBox "有文件"
acadapp.Visible = True
Dim temp() As String
Dim signer As String
Dim time As String
Dim insPoint(0 To 2) As Double '定义插入点
Dim textHeight As Double '定义文本高度
Dim textStr As String '定义文本字符
Dim textObj As Object '定义文本对象
insPoint(0) = -18990
insPoint(1) = 3424
insPoint(2) = 0
textHeight = height
textStr = "乐筑天下"
Dim ts As Object '设置字体
Set ts = acaddoc.TextStyles.Add("option")
ts.SetFont "宋体", True, False, 0, 1
acaddoc.ActiveTextStyle = ts
'创建文本对象
Set textObj = acaddoc.ModelSpace.AddText(textStr, insPoint, textHeight)
textObj.Update
textObj.StyleName = "option"
acaddoc.SaveAs ("C:\temp\temp.dwg")
'acadapp.Visible = True '使AutoCad可见
Else
MsgBox "没有此文件,请建文件,路径为:C:\temp.dwg"
Exit Function
End If
执行到打开文件后出现下面的情况:
出现一个对话框:Font not found: hztxt
我做的程序是在服务器上的,是不允许人工手动来选择对话框的。
我很疑惑,用vb在2005的环境下,打开文件可以后台执行这样一个过程,R14怎么不行啊?
我怎么解决啊? |
|