明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 878|回复: 2

设置当前文档

[复制链接]
发表于 2013-5-3 09:41 | 显示全部楼层 |阅读模式
public sub activedocument()
        dim olddoc as acaddocument
        set olddoc=thisdrawing.application.activedocument
        if Len(Dir("c:\test.dwg"))<>0 then
                thisdrawing.application.documents.open "c:\test.dwg"
        else
                msgbox "指定的文件不存在"
        end if
        thisdrawing.application.activedocument=olddoc
end sub


请教一下,如果当时CAD打开一个文件A.dwg, 然后运行这个VBA程序,C盘下也有test.dwg
那运行之后的效果是什么,test.dwg 是当前文档还是A.dwg
一本教材上的,看不大懂
 楼主| 发表于 2013-5-3 10:06 | 显示全部楼层
Public Sub openDialog()
    Dim strFileName As String
    '确保USERS1系统变量为空
    thisDrawing.SetVariable "USERS1", ""
    '显示"选择文件"对话框,并且获得用户选择的结果
    thisDrawing.sendcommand "(setvar "&" ""USERS1"""&"(getfield "&"""选择图形文件"""&"""d:/"""dwg"""&"8))"
    strFileName = thisDrawing.GetVariable("USERS1")
    '显示选择结果
    If Len(strFileName) = 0 Then
        MsgBox "为选择任何图形文件", vbInformation, "选择结果"
    Else
        MsgBox "选择的文件是:" & strFileName, vbInformation, "选择结果"
    End If
End Sub

红色的那句话是什么意思啊,那么多引号
 楼主| 发表于 2013-5-3 14:52 | 显示全部楼层
没有人回答一下?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-17 10:21 , Processed in 0.524067 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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