64位系统64位CAD的打开文件对话框
64位系统下,64位的CAD VBA 的打开文件对话框 添加 Commondialog提示“不支持止接口”。不知道用什么来打开文件或获取某文件夹下的所有文件名。 帮顶一下,我也被此问题困扰,至今未能解决,那位大侠知道的请指点一下
或者换一思路,在64位系统下,打开文件的控件commondailog变成什么了? 本帖最后由 3xxx 于 2013-12-21 13:31 编辑
我的似乎没遇到这个问题啊。
哦,看错了,我用的是vb。vba没试过。下面是vb。
比如:在64位系统下CAD2014版没问题啊。
Sub deleteraster()
'对AutoCAD部件的引用
Dim acadApp As Object '声明AutoCAD应用程序对象变量
Set acadApp = GetObject(, "AutoCAD.Application") '若AutoCAD已运行则获得它的对象实例
acadApp.Visible = True 'False
'Dim acadDoc As AcadDocument
'Set acadDoc = acadApp.ActiveDocument
Dim objName As String
Dim rasterObj As AcadRasterImage 'AcadEntity
Dim filename() As Variant
Dim FilterType(0) As Integer
Dim ftype(0) As Integer
Dim fdata(0) As Variant
Dim FilterData(0) As Variant
Dim layerObj As AcadLayer
With CommonDialog1
.CancelError = True
.MaxFileSize = 32767
.Flags = cdlOFNHideReadOnly Or cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNNoDereferenceLinks
.DialogTitle = "打开dwg文件"
.Filter = "图形文件(*.dwg)|*.dwg|所有文件(*.*)|*.*"
.filename = ""
.ShowOpen
End With
filename = ParseFileNames(CommonDialog1.filename)
'打开图形进行操作
For i = 0 To UBound(filename) 'Lbound
acadApp.Documents.open filename(i)
Set acadDoc = acadApp.ActiveDocument
'将所有图层打开,解锁,解冻
For Each layerObj In acadDoc.Layers
layerObj.Lock = False ' Not (layerObj.Lock)
'layerObj.Freeze = False ' Not (layerObj.Freeze)
layerObj.LayerOn = True ' Not (layerObj.LayerOn)
Next
'创建新选择集
Set adss = acadDoc.SelectionSets.Add("adSS")
If Err Then Set adss = acadDoc.SelectionSets.Add("adSS")
adss.Clear
ftype(0) = 0
fdata(0) = "IMAGE" 'rasterimage无效
adss.Select acSelectionSetAll, , , ftype, fdata
For Each rasterObj In adss ' acadDoc.ModelSpace'
objName = rasterObj.ImageFile 'Name 'ObjectName
objName = JustFileName1(objName) '获得图像扩展名
If objName = "jpg" Then '选择是jpg文件还是tif文件
rasterObj.Detach 'Delete
ElseIf objName = "JPG" Then
rasterObj.Detach 'Delete
End If
If Err.Number = -2145386426 Then
MsgBox imageName & " 文件未找到。"
'Exit Sub
End If
Next
acadDoc.PurgeAll '对图层和块进行清理
'关闭图形
acadDoc.Close ' True ',acadApp.Documents filename(i)
Next i
End Sub
页:
[1]