马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
VB6做的exe程序,打开dwg文件。acadapp.open 文件出现“部件忙”没有响应,点切换按钮到cad,却是空闲状态。有时候要重启cad才正常打开文件
- Dim ts As String
- Dim tsmsg As String
- Dim acadapp As AcadApplication
- On Error Resume Next
- cadfilepathd = Command$
- cadfilepathd = "C:\temp\1.dwg"
- Set acadapp = GetObject(, "AutoCAD.Application.17.1") '检测cad是否打开
- If Err.Number = 429 Then 'cad如果没有打开
- Error.Clear
- Set acadapp = CreateObject("", "AutoCAD.Application.17.1") '打开cad
- acadapp.Visible = True 'cad可见
- SendMessageBynum& acadapp.hwnd, WM_SYSCOMMAND, SC_RESTORE, 0
- SetForegroundWindow acadapp.hwnd
- BringWindowToTop acadapp.hwnd
- If acadapp.GetAcadState.IsQuiescent = True Then
- acadapp.Documents.Open cadfilepathd '打开相应文件
- acadapp.Visible = True 'cad可见
- End If
- 'SendMessageBynum& acadapp.hwnd, WM_SYSCOMMAND, SC_RESTORE, 0
- SetForegroundWindow acadapp.hwnd
- BringWindowToTop acadapp.hwnd
- Else '如果打开了
- If acadapp.GetAcadState.IsQuiescent = True Then
- acadapp.Visible = True 'cad可见
- SendMessageBynum& acadapp.hwnd, WM_SYSCOMMAND, SC_RESTORE, 0
- SetForegroundWindow acadapp.hwnd
- BringWindowToTop acadapp.hwnd
- acadapp.Documents.Open cadfilepathd '打开相应文件
- Else
- End If
- End If
|