excel 复制表格粘贴到cad里,并且是选择性粘贴cad图元。这个宏怎么写_百...

发布网友 发布时间:2024-10-23 22:30

我来回答

1个回答

热心网友 时间:2024-11-07 01:38

那个手机提问,回答有字数,没法回答。

没找到AutoCAD里面用宏粘贴的方法,只好用快捷键实现。这个宏是用于 AutoCAD 2008 的,用于其它版本可能还需要改一下。
Sub CopyFromExcelDoc()
Dim FSO As Object, WshShell As Object, VBSfile As Object
Dim VBSprocess
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
Set VBSfile = FSO.getspecialfolder(2).CreateTextFile("new.vbs", True)
VBSfile.WriteLine ("Dim WshShell, Excel, Exldoc, FSO")
VBSfile.WriteLine ("set WshShell=wscript.CreateObject(""WScript.Shell"")")
VBSfile.WriteLine ("set Excel=wscript.CreateObject(""Excel.Application"")")
VBSfile.WriteLine ("set Exldoc = Excel.Workbooks.Open(""d:\要被复制的Excel文件.xls"")")
VBSfile.WriteLine ("Exldoc.ActiveSheet.usedrange.copy")
VBSfile.WriteLine ("wscript.Sleep(200)")
VBSfile.WriteLine ("WshShell.SendKeys(""%es"")")
VBSfile.WriteLine ("wscript.Sleep(200)")
VBSfile.WriteLine ("WshShell.SendKeys(""%(pa)a{ENTER}"")")
VBSfile.WriteLine ("wscript.Sleep(200)")
VBSfile.WriteLine ("WshShell.SendKeys(""0,0 "")")
VBSfile.WriteLine ("Excel.DisplayAlerts = False")
VBSfile.WriteLine ("Excel.Quit")
VBSfile.WriteLine ("Set FSO = CreateObject(""Scripting.FileSystemObject"")")
VBSfile.WriteLine ("FSO.DeleteFile FSO.getspecialfolder(2).Path & ""\new.vbs"", True")
VBSfile.Close

Application.ActiveDocument.Activate
VBSprocess = WshShell.run(FSO.getspecialfolder(2).Path & "\new.vbs", 0)

End Sub

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com