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

Inserting a Hyperlink into Excel from AutoCAD VBA..

Status
Not open for further replies.

basepointdesignz

Programmer
Jul 23, 2002
566
GB
Hi peeps,

I have a macro (run from AutoCAD) that opens a specific Excel workbook, then inserts two truncated strings (these are made from the drawing name). This works fine everytime..

My problem is that I want to insert a hyperlink to the drawing into the workbook.. I have the following code:

Code:
' Get drawing name..
drawingname = ThisDrawing.Name

' Calculate custref length..
stringL = Len(drawingname)
custL = (stringL - 3) - 10
' Get Job number..
jobno = Left(drawingname, 8)
' Get Customer ref..
custname = Mid(drawingname, 10, custL)
custref = trade_name & "/" & custname


' Open the U.F.O. worksheet..
Set ufo = xlapp.Workbooks.Open("C:\Program Files\ToolBox 2002\AutoCAD Filez - Lighthouse\Surveys\Roof Orders\UFO.xls")
Set sheetx = xlapp.ActiveSheet

' Input text into the U.F.O. worksheet..
sheetx.Cells(3, 11) = jobno
sheetx.Cells(6, 9) = custref

' Insert Hyperlink for Survey Drawing..
fullnameX = ThisDrawing.FullName
hypText = ThisDrawing.Name
sheetx.Hyperlinks.Add Cells(6, 22), fullnameX, , hypText, hypText

' Show the U.F.O. worksheet..
xlapp.Application.Visible = True
xlapp.Application.WindowState = xlMaximized
End Sub

....This works fine once or twice but when I test it or runs more than this nothing happens - the workbook doesn't open but the Excel app does load and stays in memory..

I narrowed the problem down to the code for the hyperlink but I don't know what could be wrong..

Any ideas..

Renegade.. BULLET-PROOF DESiGNZ
renegade@tiscali.co.uk
+447919 117062 (mobile)
 
I have two possibilities that might help, but I wouldn't make book on either of them:

1. Spaces in directory of drawing names, particularly drawing names can cause strange problems.

2. Sometimes Auotcad likes two backslashes instead of one, i.e. \\ not
Let me know when you solve this problem as I have had several questioners at AllExperts.com about database problems.

Best of luck, it looks like you are well ahead of me on the VB and database side of Autocad, I concentrate heavily on LISP and production oriented routines.
 
Thanks Nebster,

Thanks for the help, buddy..

If you concentrate more on AutoLISP (which I been trying to teach myself lately too), maybe we can help each other out. I can help of try to help you out in VBA and you could help me in AutoLISP - if you like..

Anyway, let me know.. Any Q's, email me (address below)..

Cheers,

Renegade..

BULLET-PROOF DESiGNZ
renegade@tiscali.co.uk
+447919 117062 (mobile)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top