TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Tramber on March 30, 2006, 04:27:03 AM

Title: Reading Hyperlink in an Excel Cell (Hard)
Post by: Tramber on March 30, 2006, 04:27:03 AM
This is not easy I guess...

I know how to read XL cells values. that's no difficulty for me.
BUT. I'm not able to get the hyperlink written in that Cell dispite of my strong efforts.
Code: [Select]
(setq hypl(msxl-get-Hyperlinks (msxl-get-range *xlapp* "F21")))returns  #<VLA-OBJECT Hyperlinks 0024be0c>

but it seems to me that I can't do anything of it.

I tried (vla-item hypl 0) or (vla-get-url hypl),..etc...

How to read the link written in an XL cell....from AutoCAD ?  :?
Title: Re: Reading Hyperlink in an Excel Cell (Hard)
Post by: Jürg Menzi on March 30, 2006, 07:03:39 AM
try:
Code: [Select]
(vlax-for Lnk hypl
 (terpri)
 (princ (vlax-get Lnk 'Name))
)
Title: Re: Reading Hyperlink in an Excel Cell (Hard)
Post by: Tramber on March 30, 2006, 09:59:10 AM
Very nice of you.

But it gives the string corresponding to the text.

However, you inspired me !

Code: [Select]
  (vlax-for Lnk hypl(setq voir lnk))  
  (msxl-get-Address voir)

And I can get "../../../COMMUN/AABCAD/SAUV230106/Balancement/remb005.jpg", for exemple, wich would be perfect if only XL would have had been nice enough to also give the name of the directory drive.

But thank you, I made a good step
Title: Re: Reading Hyperlink in an Excel Cell (Hard)
Post by: Tramber on March 30, 2006, 10:08:31 AM
I also tried this
Code: [Select]
(vlax-for Lnk hypl(setq voir lnk))
  (setq catchit (vl-catch-all-apply 'msxl-get-Address voir))
  (vl-catch-all-error-message catchit) 

I did it in case the cell is empty of hyperlink but it doesn't seem to work

Hard  :-P
Title: Re: Reading Hyperlink in an Excel Cell (Hard)
Post by: Jeff_M on March 30, 2006, 12:37:57 PM
Using the MSX-Excel utilities that Marc'Antonio Alexi put together and posted to numerous newsgroups and a small test Excel file whose cell A:1 has a hyperlink and B:1 does not this works for me without error:
Code: [Select]
(setq #ExcelImpAllTypLib t)
(msx_loadtypelib)
(msx_openexist "c:\\test.xls" t)
(setq cell1 (msx_getsheetcell 1 1))
(setq cell2 (msx_getsheetcell 1 2))
(setq h1 (vla-get-hyperlinks cell1)
      h2 (vla-get-hyperlinks cell2)
      )
(vlax-for link h1
  (msxp-get-Address link)
  )
(vlax-for link h2
  (msxp-get-Address link)
  )
and returns:
_$

Initializing Microsoft Excel 2000...
T
"\\\\Imaging\\c\\Land Projects 3\\2002\\22115 Dennis and Barnes\\Documents\\lotcalcs.doc"
nil
_$
Title: Re: Reading Hyperlink in an Excel Cell (Hard)
Post by: Jürg Menzi on March 31, 2006, 01:49:16 AM
Thanks, Jeff for helping me out, I hadn't the time to complete my answer... :-)
Title: Re: Reading Hyperlink in an Excel Cell (Hard)
Post by: Tramber on March 31, 2006, 12:41:51 PM
cell A:1 has a hyperlink and B:1 does not this works for me without errot

My syntax :
Code: [Select]
(vlax-for Lnk hypl(setq voir lnk)) 
  (msxl-get-Address voir)

Was not very clever I confess.

Thanks to all