需要将CAD文件转换成Excel可读的文件格式,如dxf、csv等。可以使用CAD软件进行转换。然后,使用VBA代码将文件导入到Excel表格中。例如,的代码可以将dxf文件导入到Excel表格中:
1. 首先,需要将CAD文件转换成Excel可读的文件格式,如dxf、csv等。可以使用CAD软件进行转换。
2. 然后,使用VBA代码将文件导入到Excel表格中。例如,的代码可以将dxf文件导入到Excel表格中:
Sub Import_DXF()
Dim MyFileName As String
Dim MyPath As String
Dim MyTableName As String
MyPath = "C:\Users\Desktop\" '替换为你的文件路径
MyFileName = Dir(MyPath & "*.dxf")
MyTableName = InputBox("请输入表格名称:")
Do While MyFileName <> ""
Workbooks.OpenText Filename:=MyPath & MyFileName, Origin:=xlMSDOS, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar:="|"
ActiveSheet.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
ActiveSheet.Name = MyTableName
ActiveWorkbook.Close False
MyFileName = Dir()
Loop
End Sub
本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处
评论列表(18条)