Edit - Paste Special - AutoCAD Entities

Discussion in 'AutoCAD' started by Don B, Feb 25, 2004.

  1. Don B

    Don B Guest

    I'd like to copy/paste an Excel table via the clipboard into a drawing
    (paste as AC Entities & specify insertion point). I don't see any "paste
    special" commands in the AC type library. Can anyone give me a hint?
    Beginning of code looks like:

    AppActivate "Microsoft Excel"
    Sheets("Sheet1").Select
    Range(A1.G33).Copy
    AppActivate GetObject(, "AutoCAD.Application.16").Caption

    Thanks, Don
     
    Don B, Feb 25, 2004
    #1
  2. The AutoCAD ActiveX API has undergone only minimal
    enhancements, and has never fully supported things
    like paste special and other OLE related functions,
    so the only way to achive this is via the command
    processor.



    AcadX for AutoCAD 2004 Beta 1
    http://mysite.verizon.net/~vze2vjds/acadx/AcadX16.zip
     
    Tony Tanzillo, Feb 25, 2004
    #2
  3. Don B

    Don B Guest

    Tony,

    Thanks for the reply. "via the command processor" means what exactly - can
    I get away with this paste opeation using SENDKEYS commands?

    Thanks, Don
     
    Don B, Feb 25, 2004
    #3
  4. Don B

    Don B Guest

    Well, I got it down to:
    SendKeys "_pastespec" & "~" & "0.9,-3" & "~"
    But I have to manually type a "A" and "{Enter}" within the Paste Special
    dialog box. The SendKeys command won't send these commands.

    Don
     
    Don B, Feb 25, 2004
    #4
  5. Well - I'm afraid that PASTESPEC has no command line
    equivalent, so there's not much you can do about it,
    other than completely implement the command yourself
    in code (not something I would savor at all).

    The basic problem is that this command may encounter
    a variety of formats and displays them in a list box.
    Developing a command line equivalent for that is not
    trivial.



    AcadX for AutoCAD 2004 Beta 1
    http://mysite.verizon.net/~vze2vjds/acadx/AcadX16.zip
     
    Tony Tanzillo, Feb 26, 2004
    #5
  6. Don B

    Don B Guest

    Well, I'm not that smart, so I'll live with a couple of keystrokes. I could
    enter 30 or 40 pieces of data using AddText commands, but that's a lot
    grief.

    Why does SendKeys fail when the dialog box is open (they do get sent to AC
    after the dialog box is closed - not where I want 'em)? I would think that,
    if I can type it manually, SendKeys would do the same thing, but this is not
    the case.

    Thanks for your help, Don
     
    Don B, Feb 26, 2004
    #6
  7. Don B

    wivory Guest

    Don,

    I have had success sending keystrokes to dialog boxes by using the SendKeys statement just *before* they are invoked. As you are already using SendKeys though, I suggest you try invoking your _pastespec with *SendCommand* instead. So, you would have to use SendKeys first to send the "A" and "{Enter}" and immediately following that use SendCommand to send "_pastespec...".

    I have no idea if this will work in your situation, I can only tell you that similar things have worked for me.

    Good luck!

    Wayne Ivory
    IT Analyst Programmer
    Wespine Industries Pty Ltd
     
    wivory, Feb 26, 2004
    #7
  8. Don B

    wivory Guest

    In case what I'm saying is confusing, here is an example of where I've used it. Sometimes when debugging I'll stick a MsgBox statement in the code to stop proceedings. But it annoyed me that the message box always appeared in the middle of the screen and I'd have to drag it out of the way to see the drawing. Well, necessity is the mother of invention so after a bit of experimentation I discovered I could do this:

    SendKeys "% m{DOWN 22}{RIGHT 32}{ENTER}" ' Drag the subsequent Message Box into the corner so we can see the drawing
    MsgBox ""

    Try it out in a test procedure, you'll see what I mean.

    Regards

    Wayne
     
    wivory, Feb 26, 2004
    #8
  9. Don B

    Don B Guest

    YES!! - that does it. Thank's Wayne!

    'Edit - Paste Special - AutoCAD Entities:
    'Note: send the A & {Enter} before the SendCommand statement for dialog box:
    SendKeys "A" & "~"
    ac.ActiveDocument.SendCommand "_pastespec" & vbCr & "0.9,-3" & vbCr

    Don
     
    Don B, Feb 26, 2004
    #9
  10. Don B

    Ed Jobe Guest

    Sendkeys is a vb method, not acad. I just sends chars to the *active*
    window. When the dialog pops up, the window it was sending to, goes out of
    focus.
     
    Ed Jobe, Feb 26, 2004
    #10
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.