Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Excel.Interop OLE -> Problem beim Hyperlink lesen (https://www.delphipraxis.net/121303-excel-interop-ole-problem-beim-hyperlink-lesen.html)

Master_BB 25. Sep 2008 10:51


Excel.Interop OLE -> Problem beim Hyperlink lesen
 
Hy,
ich habe gerade das Problem das ich wenn ich einen Hyperlink auslese immer ein "Mitglied nicht gefunden" fehler bekomme.
Code sieht so aus
Delphi-Quellcode:
  FExcel        := CreateOleObject('Excel.Application');
  FExcelWorkBook := FExcel.Workbooks.Open(AFilePath);
  ACount        := FExcelWorkbook.ActiveSheet.Hyperlinks.Count;
  AHypLink      := FExcelWorkbook.ActiveSheet.Hyperlinks.Item(1); //->fehler obwohl ACount = 2
das selbe bei Word läuft ohne probleme.

Weiß jemand was der Key für die Items in der Hyperlinks liste ist? In word wars einfach durchnummeriert,
hier könnten es ja Col+Row oder A1....An sein.

Wenn jemand nen Tip hat wäre das außerordentlich schön

gruß

Master_BB 25. Sep 2008 12:23

Re: Excel.Interop OLE -> Problem beim Hyperlink lesen
 
ok ich hab das problem jetzt selber gelößt und zwar läuft der Code wenn man Hyperlinks als Array auffasst.
Delphi-Quellcode:
  FExcel        := CreateOleObject('Excel.Application');
  FExcelWorkBook := FExcel.Workbooks.Open(AFilePath);
  ACount        := FExcelWorkbook.ActiveSheet.Hyperlinks.Count;
  AHypLink      := FExcelWorkbook.ActiveSheet.Hyperlinks[1];
bei Word jedoch funktioniert es auch so
Delphi-Quellcode:
AHypLink := FWord.ActiveDocument.Hyperlinks.Item(AHypLinkIdx);
Das ist komisch, ist aber so g.

Gruß

DUCATI9 1. Feb 2009 16:17

Re: Excel.Interop OLE -> Problem beim Hyperlink lesen
 
Hallo MasterBB,

ich stecke soeben über dem selben Problem, wo Du die Lösung gefunden hast, ich aber nicht anwenden kann.

Meine Problem, ich möchte aus einer Excel Tabelle aus Zellen die Hyperlinks auslesen.

Leider funktioniert folgendes nicht.

linktext,link : String;

linktext:=ExcelApp.Cells[1,1].Value;
if ExcelApp.Activecell.Hyperlinks.count>0 then
link:=ExcelApp.ActiveCell.Hyperlinks[1];

Die Fehlermeldung lautet ... Variante des Type Dispatch konnten nicht in String konvertiert werden.

Wie kann ich einfach aus einer Zelle den Link auslesen?

Vielen Dank für eure Hilfe!

Grüsse

Robert

Master_BB 2. Feb 2009 15:11

Re: Excel.Interop OLE -> Problem beim Hyperlink lesen
 
auf die schnelle würd ich meinen das bei 0 angefangen wird zu zählen
daher probiers mal mit
link:=ExcelApp.ActiveCell.Hyperlinks[0];

buchsbaum 13. Jul 2010 08:41

AW: Excel.Interop OLE -> Problem beim Hyperlink lesen
 
Hallo

Ich habe ebenfalls versucht, die Hyperlinks aus einer Excel-Datei auszulesen. Dazu habe ich den oben genannten Code verwendet:

AHypLink := FExcelWorkbook.ActiveSheet.Hyperlinks[1];

Leider weiß ich nicht genau, welchen Datentyp ich für AHypLink definieren muss.

shmia 13. Jul 2010 09:09

AW: Excel.Interop OLE -> Problem beim Hyperlink lesen
 
Zitat:

Zitat von buchsbaum (Beitrag 1035060)
Leider weiß ich nicht genau, welchen Datentyp ich für AHypLink definieren muss.

Delphi-Quellcode:
var
  AHypLink : OleVariant;
Mit AHypLink.Address müsstest du an den Link als String kommen.

Hier noch das Interface dazu:
Code:
 interface IHyperlink : IDispatch {
        [propget, helpcontext(0x00010094)]
        HRESULT _stdcall Application([out, retval] Application** RHS);
        [propget, helpcontext(0x00010095)]
        HRESULT _stdcall Creator([out, retval] XlCreator* RHS);
        [propget, helpcontext(0x00010096)]
        HRESULT _stdcall Parent([out, retval] IDispatch** RHS);
        [propget, helpcontext(0x0001006e)]
        HRESULT _stdcall Name([out, retval] BSTR* RHS);
        [propget, helpcontext(0x000100c5)]
        HRESULT _stdcall Range([out, retval] Range** RHS);
        [propget, helpcontext(0x0001062e)]
        HRESULT _stdcall Shape([out, retval] Shape** RHS);
        [propget, helpcontext(0x000105bf)]
        HRESULT _stdcall SubAddress([out, retval] BSTR* RHS);
        [propput, helpcontext(0x000105bf)]
        HRESULT _stdcall SubAddress([in] BSTR RHS);
        [propget, helpcontext(0x000100ec)]
        HRESULT _stdcall Address([out, retval] BSTR* RHS);
        [propput, helpcontext(0x000100ec)]
        HRESULT _stdcall Address([in] BSTR RHS);
        [propget, helpcontext(0x0001006c)]
        HRESULT _stdcall Type([out, retval] long* RHS);
        [helpcontext(0x000105c4)]
        HRESULT _stdcall AddToFavorites();
        [helpcontext(0x00010075)]
        HRESULT _stdcall Delete();
        [helpcontext(0x00010650)]
        HRESULT _stdcall Follow(
                        [in, optional] VARIANT NewWindow,
                        [in, optional] VARIANT AddHistory,
                        [in, optional] VARIANT ExtraInfo,
                        [in, optional] VARIANT Method,
                        [in, optional] VARIANT HeaderInfo);
        [propget, helpcontext(0x0001075b)]
        HRESULT _stdcall EmailSubject([out, retval] BSTR* RHS);
        [propput, helpcontext(0x0001075b)]
        HRESULT _stdcall EmailSubject([in] BSTR RHS);
        [propget, helpcontext(0x00010759)]
        HRESULT _stdcall ScreenTip([out, retval] BSTR* RHS);
        [propput, helpcontext(0x00010759)]
        HRESULT _stdcall ScreenTip([in] BSTR RHS);
        [propget, helpcontext(0x0001075a)]
        HRESULT _stdcall TextToDisplay([out, retval] BSTR* RHS);
        [propput, helpcontext(0x0001075a)]
        HRESULT _stdcall TextToDisplay([in] BSTR RHS);
        [helpcontext(0x0001075c)]
        HRESULT _stdcall CreateNewDocument(
                        [in] BSTR Filename,
                        [in] VARIANT_BOOL EditNow,
                        [in] VARIANT_BOOL Overwrite);
    };


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:20 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz