Author Topic: Reading Hyperlink in an Excel Cell (Hard)  (Read 3379 times)

0 Members and 1 Guest are viewing this topic.

Tramber

  • Guest
Reading Hyperlink in an Excel Cell (Hard)
« 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 ?  :?

Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
Re: Reading Hyperlink in an Excel Cell (Hard)
« Reply #1 on: March 30, 2006, 07:03:39 AM »
try:
Code: [Select]
(vlax-for Lnk hypl
 (terpri)
 (princ (vlax-get Lnk 'Name))
)
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18

Tramber

  • Guest
Re: Reading Hyperlink in an Excel Cell (Hard)
« Reply #2 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

Tramber

  • Guest
Re: Reading Hyperlink in an Excel Cell (Hard)
« Reply #3 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

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Reading Hyperlink in an Excel Cell (Hard)
« Reply #4 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
_$

Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
Re: Reading Hyperlink in an Excel Cell (Hard)
« Reply #5 on: March 31, 2006, 01:49:16 AM »
Thanks, Jeff for helping me out, I hadn't the time to complete my answer... :-)
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18

Tramber

  • Guest
Re: Reading Hyperlink in an Excel Cell (Hard)
« Reply #6 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