Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert a Block from Access

Status
Not open for further replies.

sgfromny

Technical User
Joined
Jan 17, 2003
Messages
120
Location
US
Could anyone provide some basic code from access vba on inserting a block? Im having trouble understanding how to gain access to the Autocad enviornment from ACCESS.

Im assuming that Autocad will be running in the background, and I just want to call the current drawing, and simply place a block at 0,0

Any help would be greatly appreciated!
Thanks
 
Hi sgfrommy,

You'll need to set a reference to the AutoCAD application, you can either early or late binding and then set a reference to the current document, then decide which "space" the block will be inserted, (either paper space or model space), and then insert the block.

Early binding:

Code:
Dim AcadApp as AutoCAD.Application
Dim AcadDoc as AutoCAD.Document
 
On Error Resume Next
    
Set AcadApp = GetObject(, "AutoCAD.Application")
  
If Err Then
  ' AutoCAD is not running, start it:
  '
  Err.Clear
  Set AcadApp = CreateObject("Autocad.Application")
    
  AcadApp.Visible = True
    
  ' Was the routine able to launch AutoCAD?
  '
  If Err Then
    ' Won't be able to continue, notify user and get out.
    '
    MsgBox("Couldn't launch AutoCAD")
  End
  End If
Else
  AcadApp.Visible = True
          
  Set AcadDoc = AcadApp.ActiveDocument
        
End If

HTH
Todd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top