Jump to content

Recommended Posts

Posted

Hi,

 

I am writing a visual lisp program, invoking Microsoft Excel to make modificatins in an existing .xlsx fle.

 

How can I put a hyperlink text inside a cell?

 

Mehrdad Ahankhah

Posted (edited)
code removed

Edited by Lt Dan's legs
Posted

@Lt Dan's legs: Absolutely NO! By opening an Excel file (a formatted file) in text mode you will destroy it! Check on the forum, there are already examples regarding Excel file access from AutoLISP available.

 

Regards,

Posted

WOW, did not know that! Sorry Ahankhah and thanks for the heads up msasu

Posted

I'm not sure I completely understand your question Ahankhah: do you wish to link two text items in AutoCAD & Excel so that if one is modified, the change is reflected in the other?

 

Or are you merely looking to copy a text item to Excel? Or use a hyperlink in AutoCAD to open Excel?

Posted
I'm not sure I completely understand your question Ahankhah: do you wish to link two text items in AutoCAD & Excel so that if one is modified, the change is reflected in the other?

 

Or are you merely looking to copy a text item to Excel? Or use a hyperlink in AutoCAD to open Excel?

 

Lee Mac, I found the solution of my instant problem, but you mentioned to the subsequent question of me. Do you know how I can link a text in a cell of excel spreadsheet to some information about an drawing:?? For instance, am I able to show the number of lines in a drawing in an excel file, so that when the number changes the text in excel spreadsheet changes to the new amount:huh:? I hope I could express my idea:unsure:!

 

Mehrdad Ahankhah

www.irancad.com

Posted (edited)

Lt Dan's legs,

although msasu is right, you gave me the clue.

Here is my code using your offer:

 

(vl-load-com)
(setq excel     (vlax-create-object "Excel.Application")
     workbooks (vlax-get-property excel 'Workbooks)
     workbook  (vlax-invoke-method workbooks 'Open "test.xls")
     sheet     (vlax-get-property excel 'Activesheet)
     cells     (vlax-get-property sheet 'Cells)
     data      '("This"                "is"
                 "an"                  "example"
                 "of"                  "inserting"
                 "text"                "and"
                 "hyperlink"           "in"
                 "excel"               "spreadsheet:"
                 "=HYPERLINK(\"cadtutor.net\";\"cad tutor\")"
                )
)
(setq row 1)
(setq column 0)
(foreach item data
   (setq column (1+ column))
   (vlax-put-property cells 'Item row column item)
)
(vlax-invoke-method workbook 'Save)
(vlax-invoke-method workbooks 'Close)
(vlax-invoke-method excel 'Quit)
(vlax-release-object cells)
(vlax-release-object sheet)
(vlax-release-object workbook)
(vlax-release-object workbooks)
(vlax-release-object excel)
(gc)

 

I appreciate your help and want to thank you:D.

Edited by Ahankhah
changed , to ; in the code: "=HYPERLINK(\"cadtutor.net\";\"cad tutor\")"
Posted
Lee Mac, I found the solution of my instant problem, but you mentioned to the subsequent question of me. Do you know how I can link a text in a cell of excel spreadsheet to some information about an drawing:?? For instance, am I able to show the number of lines in a drawing in an excel file, so that when the number changes the text in excel spreadsheet changes to the new amount:huh:? I hope I could express my idea:unsure:!

 

Mehrdad Ahankhah

www.irancad.com

 

Hmm.. a tough one - a reactor springs to mind, but it wouldn't be easy to implement. Unless there is a way to somehow accomplish this with fields...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...