Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I need to create a script to link data from excel in several files autocad.
Solved! Go to Solution.
I need to create a script to link data from excel in several files autocad.
Solved! Go to Solution.
Unfortunately a script will work properly. On the "Pastespec" menu you should use "Paste Link" and you either have to press the radio button manually or press "Alt+L".
However you can accomplish this with VBA in excel with ease!
Open excel, Press "Alt+F11" to open VBA.
Insert > Module
Paste this code:
Sub sbACAD() Dim objAutoCAD As Object On Error Resume Next Set objAutoCAD = GetObject(, "AutoCAD.Application") On Error GoTo 0 If objAutoCAD Is Nothing Then Application.CutCopyMode = False MsgBox "AutoCAD is not running", vbOKOnly, "Error" Cells(3, 5).Select Else: AppActivate "AutoCAD" objAutoCAD.WindowState = 3 SendKeys ("pastespec") SendKeys "{ENTER}" Application.Wait Now + TimeValue("00:00:01") SendKeys ("%(L)") SendKeys "{DOWN}" SendKeys "{ENTER}" End If End Sub
You can even have the table placed automatically with this: Make sure to change the coordinates to what you want.
Application.Wait Now + TimeValue("00:00:12") SendKeys ("13.767{TAB}21.044") SendKeys "{ENTER}"
I inserted a wait time because for me Datalinks are a bit slow.
Once you save the macro press "Alt+F8" to open the macro window.
Dont forget to highlight your cells and press "Ctrl+C" before running the macro!!!
jhonatan thanks for the response.
I'm testing the macro you have sent me but I error in the following line:
Else: AppActivate "AutoCAD"
with this macro it is what I get dump a table autocad excel?
Best Regards.
Jesus Maria Sagarduy.
hello jhonatan
I've been a little busy these days, I am now taking up the work with data link.
you excel file attachment sending and file cad with whom I generally dwg's collection. each excel sheet must be a worksheet cad.
reggards.
Jesús Mª Sagarduy
I'm unable to load an xlsm file here, so I uploaded it to my dropbox.
Download from here
I created a button next to each table that says "<Datalink".
Upon pushing the button, Excel will switch to AutoCAD and automate the Datalink process.
If AutoCAD is not running, it will display a message saying, "AutoCAD is not running!"
I hope it helps!
Hi Jonathan
thank you very much for excel you have sent me. I will be very useful !!
a greeting from Bilbao.
Jesus Maria Sagarduy.
Hi Jonathan an J. Maria.
Could you please reupload the Excel file ?
Thanks!!