Excel/VBA/Autocad problem

C

CLR

Hi All.......

I'm just beginning in VBA and have a macro I'm writing in Excel to open
Autocad and that part works fine........but now I want to pass commands to
the Autocad Command line and I can't get it to work because of the error msg
stating "Object required".......I take it that VBA is not getting "into"
Autocad to pass the commands, only "opening" it.......I'm using

VBA.Shell "dadadada.dwg"
to get Autocad open............
then it will not recognize .......
thisdrawing.sendcommand "dododo"........

I hope I've explained it well enough........can anyone help please?

TIA
Vaya con Dios,
Chuck, CABGx3
 
P

Perry

Have you set a reference to the AutoCad library?
(VBE menu: Tools | References)

If you can set a reference to this library, you can control
AutoCad from within VBA possibly making VBA.Shell obsolete.

Krgrds,
Perry
 
C

CLR

Hi Perry.......

Thanks for responding.........no, I haven't done that. Have no idea what
you're talking about but will try .........I assume I just put that (VBE
menu: Tools | References) in as a line of code instead of the Shell
command?

Vaya con Dios,
Chuck, CABGx3
 
C

Cindy M -WordMVP-

Hi Clr,

1. You really need to follow up on this in a newsgroup that specializes in
AutoCad programming. This is a group for Microsoft WORD :)

2. From within Tools/References you select the AutoCad object library. That
will tell your EXCEL(?) VBA project it needs to access the AutoCad programming
language. Without that, you can't use things like "thisdrawing.sendcommand"
because another program has no idea what you're talking about. It would be
like someone walking through your door and talking about what "Jack" just did,
but you have no idea who "Jack", so that conversation is meaningless for you
until someone tells gives you background information about "Jack".

3. Once you've done this, you need to set up object variables that deal with
AutoCad. I've never used AutoCad, much less automated it (no "Reference" <g>),
so I'll show you how this would look for automating Word from Excel:
Dim wd as Word.Application
Dim doc as Word.Document

Set wd = CreateObject("Word.Application")
Set doc = wd.Documents.Add
doc.Range.Text = "Hello world!"
doc.SaveAs "My test.doc"
doc.Close
wd.Quit
Set doc = Nothing
Set wd = Nothing

You'll need to ask in an AutoCad group what to use in place of
Word.Application to start up AutoCad, etc.
Thanks for responding.........no, I haven't done that. Have no idea what
you're talking about but will try .........I assume I just put that (VBE
menu: Tools | References) in as a line of code instead of the Shell
command?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
C

CLR

Many thanks Cindy and Perry, and I apologize to all for posting in the wrong
group.......

Great Holiday greetings to all

Vaya con Dios,
Chuck, CABGx3
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top