PDA

View Full Version : Hyperlink in Access to layout



Wanderer
2004-07-19, 04:18 PM
I have a database of drawings, and I have hyperlinks in a field in the database that will take me to the file. BUT, now I want to link another field to a specific layout in a drawing.

Say the drawing name is north.dwg and the layout name is 'A'. Can I append that hyperlink with something telling it to open with that specific layout?

Thanks for any help you can give me.

Ed Jobe
2004-07-19, 04:46 PM
That would be a bookmark in a url. I don't think that a dwg supports that, but dwf does. You would have to create a macro to go to the layout that you could execute from Access.

Wanderer
2004-07-19, 04:54 PM
That would be a bookmark in a url. I don't think that a dwg supports that, but dwf does. You would have to create a macro to go to the layout that you could execute from Access.
I shoulda figured that would be the case.
Well, with these, I won't be having too many different ones, so, doing dwf might not be too bad, but I just finally got the new dwg viewer pushed to my guys, they resisted that (can't we still use volo view express??? NO!) and I can't imagine the hassle of trying to push something else out to them (they can't install anything on their pc's, they have to call in the techies for that).

~sigh~ If you get bored enough to write a macro for that, I'd be happy to test it out for you. :)

Thanks for the answer!

Ed Jobe
2004-07-19, 06:26 PM
I'm assuming that your "hyperlink" is using the "file://" protocol. If so, and depending on what version of acad you are using, you can use the "/layout" startup switch.

Wanderer
2004-07-19, 07:28 PM
I had tried to browse to the location in the file (which is only supported with databases), and I tried modifying the hyperlink with the switch, but that didn't work, and I just typed in the switch in the 'named location in file' field and that still didn't work.

~sigh~

Ed Jobe
2004-07-19, 07:57 PM
Sorry, I steered you wrong. The comand line switch will only work sending a dos command. Like when using SHELL. Abandon the Hyperlink route and open it with vba. Are you working with a form or just a table? What is the form's name? What are the field names where the path and layout are stored? I'll give you a sub that concatenates the fields and opens the dwg.

Wanderer
2004-07-19, 08:07 PM
Sorry, I steered you wrong. The comand line switch will only work sending a dos command. Like when using SHELL. Abandon the Hyperlink route and open it with vba. Are you working with a form or just a table? What is the form's name? What are the field names where the path and layout are stored? I'll give you a sub that concatenates the fields and opens the dwg.I'm sorry, I'm only 24, I've never heard of DOS. ;) j/k

Um, showing my dumb here, what's shell? open what with vba?

I am doing the hyperlinking in the access table, but, people will be viewing it from a form. (eventually :Oops: )

I'll pick a table that has a form already.
The file is PlansIndex.mdb
Table is AbsolutelyEverything
Form is AbsolutelyEverything Query
Field where hyperlink is stored is AREA_LINK


concatenates? whaaat?

Ed Jobe
2004-07-19, 09:30 PM
The following will open a dwg in acad, whether or not acad is running. You will need to create a new field called "Layout" for storing the name of the layout to move to. Open the form and put it in design mode. To get this to run when the user double clicks in the path field, open the properties window and click on the AREA_LINK field. Next, click on the Event tab and then in the combo box for the On Dbl Click event, select "(Event Procedure)". Click on the elipsis (...) button next to the dropdown arrow and you will be taken the the vba editor for this event. Paste the code I gave you there. While in the vba editor, go to the Tools menu, References and check "Autocad 2xxx Type Library", where xxx is the version you are using. Save the form, the code is stored in the form. Don't forget to get rid of the hyperlinks. All the AREA_LINK field needs to store is the text for the path.


Private Sub AREA_LINK_DblClick(Cancel As Integer)

Dim dwg As AcadDocument

On Error Resume Next
Set acad = GetObject(, "AutoCAD.Application")
If Err <> 0 Then
Set acad = CreateObject("AutoCAD.Application")
Exit Sub
End If
'switch to acad and open the file
acad.Visible = True
AppActivate acad.Caption
' different process for SDI and MDI modes
With AcadApplication
If .Preferences.System.SingleDocumentMode = True Then
ThisDrawing.Open [AREA_LINK]
Else
'Use the application object.
'ThisDrawing object will not be
'available when all docs are closed.
Set dwg = .Documents.Add([AREA_LINK])
End If
End With
dwg.ActiveLayout = dwg.Layouts.Item([Layout])
Set acad = Nothing

End Sub


I'm sorry, I'm only 24, I've never heard of DOS. ;) j/k

Um, showing my dumb here, what's shell? open what with vba?

concatenates? whaaat?

Shell is an os command that enables one program to start another one. This functionality is also avaiable to vba. Concatanation is the process of linking together in a series. In programming, it means to joing two or more strings together into one string. However, since I'm using vba, I did not go with joining the path and layout into a command line string. I'm just opening acad directly from vba.

Wanderer
2004-07-20, 12:11 PM
I'll try this out and let you know what I manage do mess up. :confused:

:lol: Thanks so much!