请问VBA中怎样在R14中插入dwg文件?
以下代码错在何处?Dim InsetPoint(0 To 2) As Double
Dim ImporFile As String
InsetPoint(0) = 0: InsetPoint(1) = 0: InsetPoint(2) = 0
ImporFile = "文件名.dwg"
ThisDrawing.Import ImporFile, InsetPoint, 1# 文件名必须带路径,不然就必须在当前目录存在,但当前目录有时会有不同,所以还是加上路径为好。
带上路径仍然不行!
该文件名已是带上路径的全文件名,但是执行代码后什么也没有,既没见到欲插入的图形文件,也没有提示错误,不知何故? ThisDrawing.ModelSpace.InsertBlock InsetPoint, ImporFile, 1, 1, 0 RetVal = object.Import(FileName, InsertionPoint, ScaleFactor)
Object
Document
The object or objects this method applies to.
FileName
String; input-only
The name of the file to be imported.
InsertionPoint
Variant (three-element array of doubles); input-only
The 3D WCS coordinates location in the current drawing where the imported file is placed.
ScaleFactor
Double; input-only
The scale used to place the imported file.
RetVal
Object
In the case of importing a WMF file, a BlockReference object is returned. In all other cases, the return value is NULL.
最后一个的返回值介绍:
返回
导入WMF文件,返回块引用对象。其它情况,返回NULL值。 改成以下代码仍不行:
Dim InsetPoint(0 To 2) As Double
Dim ImporFile As String
Dim ScaleFactor As Double
Dim AnObj As Object
InsetPoint(0) = 0: InsetPoint(1) = 0: InsetPoint(2) = 0
ImporFile = "D:\123.dwg"
ScaleFactor = 1#
Set AnObj = ThisDrawing.Import(ImporFile, InsetPoint, ScaleFactor)
查了一下,是否 import 方法不支持 .dwg 文件?然则 .dwg 文件怎样插入? Impor只支持WMF文件的导入,对于DWG文件,就要使用插入块或者外部引用的方式。 再请问一下,将DWG文件作为块插入或者外部引用在VBA中如何实现之?麻烦编一小段代码将“D:\123.dwg"文件插入当前图形,不甚感谢!最好能在R14中通过。
<新手上路,请多指教>:) 请各位大侠指点!谢谢! 我知道我提的问题太过简陋,不值一哂,但是新手上路。还望海涵:
麻烦哪位编一小段代码将“D:\123.dwg"文件插入当前图形,不甚感谢!最好能在R14中通过。
页:
[1]
2