zoukankan      html  css  js  c++  java
  • VB操作CAD

     Dim xlapp As Excel.Application
                Dim xlbook As Excel.Workbook
                Dim sheet As Excel.Worksheet

                Dim Range As Excel.Range

            Dim zwcadapp As ZwcadApplication
            
            Dim obj As Excel.OLEObject
            
            
            
            Set xlapp = New Excel.Application
    '        Set xlbook = xlapp.Workbooks.Add
    '        Set xlapp = New Excel.Application
    '        Set xlapp = CreateObject("Excel.Application")
            Set xlbook = xlapp.Workbooks.Add
            Set xlsheet = xlbook.Worksheets.Add
            xlapp.Visible = True
            xlsheet.Cells(1, 1) = "测试" '写入内容
            Set Range = xlsheet.Range("B2")
            
            
            Range.Select
            Set obj = xlsheet.OLEObjects.Add(FileName:="E:DataEgPROGRAMMiTOPBOTSmt.dwg", Link:=True, DisplayAsIcon:=False)
            obj.Verb Verb:=xlPrimary
            On Error Resume Next
            Set zwcadapp = GetObject(, "ZwCAD.Application")
            If Err Then
                MsgBox ("CAD启动错误")
                Exit Sub
            End If
            zwcadapp.Visible = False
            zwcadapp.WindowState = acMax
            zwcadapp.ZoomExtents   '可以显示图形的全部,使绘制的图形最大限度地充满绘图区域
            zwcadapp.ActiveDocument.Save
            zwcadapp.ActiveDocument.Close
            zwcadapp.Quit
            Set zwcadapp = Nothing










     Dim zwcadapp As ZwcadApplication
            
            Dim obj As Excel.OLEObject
            
            range.Select
            Set obj = objsheet.OLEObjects.add(FileName:=strFileName, Link:=True, DisplayAsIcon:=False)
            obj.Verb Verb:=xlPrimary
            
            On Error Resume Next
            Set zwcadapp = GetObject(, "ZwCAD.Application")
            If Err Then
                MsgBox ("CAD启动错误")
                Exit Sub
            End If
            zwcadapp.Visible = False
        
            zwcadapp.WindowState = zcMax
            zwcadapp.ZoomExtents   '可以显示图形的全部,使绘制的图形最大限度地充满绘图区域
            
            
            zwcadapp.ActiveDocument.SetVariable ("filedia"), 0                '''''''''''''''''''''''''禁止弹出对话框
            
            zwcadapp.ActiveDocument.Save
            zwcadapp.ActiveDocument.Close
            
            zwcadapp.Quit
            Set zwcadapp = Nothing
               
               
            With obj.ShapeRange
                .Fill.Visible = msoTrue
                .Fill.Solid
                .Fill.ForeColor.SchemeColor = 65
                .Fill.Transparency = 1#                '透明度100%
                .Line.Weight = 0.75
                .Line.DashStyle = msoLineSolid
                .Line.Style = msoLineSingle
                .Line.Transparency = 0#
                .Line.Visible = msoFalse
            End With
            
            If isSMT = True And isPagesizeA3 = True Then
                With obj.ShapeRange
                    .IncrementTop 25#
                End With
            End If
            If isSMT = True And isPagesizeA3 = False Then
                With obj.ShapeRange
                    .LockAspectRatio = msoTrue
                    .width = 570#
                    .IncrementTop 100.25
                End With
            End If
            
            If isSMT = False And isPagesizeA3 = True Then
                With obj.ShapeRange
                    .LockAspectRatio = msoTrue
                    .width = 588#
                    .IncrementLeft 229#
                End With
            End If
            
            If isSMT = False And isPagesizeA3 = False Then
                With obj.ShapeRange
                    .LockAspectRatio = msoTrue
                    .width = 570#
                    .IncrementLeft 143#
                End With
            End If
  • 相关阅读:
    微信公众号,点击菜单,跳转到小程序
    tomcat启动时启动窗口出现乱码的解决方案
    SpringBoot实现HandlerInterceptor拦截器的接口没有需要重写的方法也不报错是怎么回事
    ZooKeeper下载安装(Windows版本)
    Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could
    mysql连接出现java.sql.sql exception:服务器时区值'''_''''无法识别或表示多个时区
    angular执行ng build进行压缩。
    angular新建项目时没有新建路由时,后来新建路由
    关于ng-zorro-antd阿里的UI框架
    angular 项目创建打包过程
  • 原文地址:https://www.cnblogs.com/wuyuxin/p/7017346.html
Copyright © 2011-2022 走看看