Paste Special as Link

Paste Special as Link

Anonymous
Not applicable
1,711 Views
6 Replies
Message 1 of 7

Paste Special as Link

Anonymous
Not applicable

I am trying to figure out a LISP routine to paste an Excel table into a AutoCAD 2014 layout as a link. The current way of doing this is by >PasteSpec>Paste Link>AutoCAD Entities>*select the base point to paste*

 

Is there anyone who can help me out with this, it would really streamline my work if I could type one command, hit one button to do all that.

 

Thank You.

0 Likes
1,712 Views
6 Replies
Replies (6)
Message 2 of 7

chriscowgill7373
Advisor
Advisor
(defun c:pastetable	(/ cla) ; _pst - inserts new table without header
      (vl-load-com)
      (setq cla (getvar "clayer"))
      (command "layer" "make" "XA-TEXT" "color" "3" "XA-TEXT" "")
      (command "color" "bylayer")
      (command
	"insert"
	"tbstyle.dwg"
      ) ;_ end of command
      (command)
      (command)
      (setvar "ctablestyle" "Engineering")
      (command "_pastespec" pause)
      (command "purge" "b" "tbstyle" "N")
      (setvar "clayer" cla)
    ) ;_ end of defun

is all that I have.  the problem is, there is no command line interface for paste special, so you cant really lisp it.  the tblstyle.dwg contained our Engineering table style definition.

 


Christopher T. Cowgill, P.E.

AutoCAD Certified Professional
Civil 3D Certified Professional
Civil 3D 2024 on Windows 10

Please select the Accept as Solution button if my post solves your issue or answers your question.

Message 3 of 7

Anonymous
Not applicable

Okay, as I am new to this whole side of AutoCAD, what would be the best way to implement this? Would I save it as a .lsp, or is this considered more of a macro?

 

Please excuse my ignorance, Thanks Folks.

0 Likes
Message 4 of 7

chriscowgill7373
Advisor
Advisor

I'd save it as a .lsp file then load it.  if you dont have a startup lisp routine, you can add it to the startup suite and have it load there.  I'd tweak a few things as my blocks and paths and styles are different than what you are probably using.

 


Christopher T. Cowgill, P.E.

AutoCAD Certified Professional
Civil 3D Certified Professional
Civil 3D 2024 on Windows 10

Please select the Accept as Solution button if my post solves your issue or answers your question.

0 Likes
Message 5 of 7

Anonymous
Not applicable

Okay, so we have a lisp routine that is auto loaded, so I put my PasteSpec.lsp in the start up suite with it, but it keeps telling me the lisp had failed to load. I attached a picture of my command window immediately after starting up AutoCAD. I made sure where I saved my lisp is in a trusted location.

0 Likes
Message 6 of 7

Anonymous
Not applicable

Is there anyway to make a Macro that complicated that would produce the same results?

0 Likes
Message 7 of 7

Jonathan3891
Advisor
Advisor

I use VBA inside excel to paste my excel link.

 

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

Jonathan Norton
Blog | Linkedin