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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2000 Linked Docs

Status
Not open for further replies.

Jables

Programmer
Aug 28, 2001
148
US
Here's what I'm trying to accomplish. When a user selects a value of a combo box, an AutoCAD drawing pops up (the drawing is, of course, dependent on which value the user selects in the combo box). So here's what I've done:

1. I insert an unbound object onto the form from the Toolbox. This wizard pops up and I have to choose "Creat New" and specify that it will be an AutoCAD drawing. I name the unbound object OLE1.

2. I associate the following code with the combo box's After_Update event:

Private Sub cbo1_AfterUpdate()
If Me.cbo1 = "Value 1" Then
Me.OLE1.Class = "AutoCAD.Drawing.14"
Me.OLE1.OLETypeAllowed = acOLELinked
Me.OLE1.SourceDoc = "T:\DWG\BLOCKS\drawing1.dwg"
Me.OLE1.Action = acOLECreateLink
Me.OLE1.SizeMode = acOLESizeZoom
Else If Me.cbo1 = "Value 2" Then
etc, etc,

So anyway, the program gets stuck as soon as it hits the OLE1.Action = acOLECreateLink line. I get a run-time error (error 2637, I think) and it says it's unable to perform the action specified. Also none of the properties of OLE1 ever change. That is, the Source Doc is still blank and the OLE Type is still "Embedded."

So what can I do here? Any help would be more than appreciated.


 
Check the documentation(if you can find any) of AutoCad objects to see if you can have it as Linked. I recently had a similar problem and the reason was the objexts I was trying to link could only be embedded.
 
I've been informed that you cannot link an AutoCAD drawing. It can only be embedded.

I did try this code using OLETypeAllowed = Embedded, but it still would not execute. Keeps getting hung on the acOLECreateLink line. Do you use acOLECreateLink regardless of whether the object is embedded or linked? I am pretty new to Access so perhaps I'm doing something absurdly stupid. Maybe I'm just not using the correct syntax.
 
I don't know Auto CAd, but I know it supports VBA. IF that's the case, then accessing it would be just like any other OLE component. You'll have to set refernce to the AutoCad object library first.


Dim objCad As Object
Dim Filen
'Location of the file
Filen = me.cboYourCombo
Set objCad = New AutoCad.Application
With objCad
'Open the file
.Documents.Open FileName:=Filen 'I don't know the exact model. this is Words
'Activate it
.Documents(1).Activate
'Make sure it's visible
.Visible = True
End With
'Maximize the window
objCad.Application.WindowState = wdWindowStateMaximize
End Function Tyrone Lumley
augerinn@gte.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top