![]() |
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:
das selbe bei Word läuft ohne probleme.
FExcel := CreateOleObject('Excel.Application');
FExcelWorkBook := FExcel.Workbooks.Open(AFilePath); ACount := FExcelWorkbook.ActiveSheet.Hyperlinks.Count; AHypLink := FExcelWorkbook.ActiveSheet.Hyperlinks.Item(1); //->fehler obwohl ACount = 2 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ß |
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:
bei Word jedoch funktioniert es auch so
FExcel := CreateOleObject('Excel.Application');
FExcelWorkBook := FExcel.Workbooks.Open(AFilePath); ACount := FExcelWorkbook.ActiveSheet.Hyperlinks.Count; AHypLink := FExcelWorkbook.ActiveSheet.Hyperlinks[1];
Delphi-Quellcode:
Das ist komisch, ist aber so g.
AHypLink := FWord.ActiveDocument.Hyperlinks.Item(AHypLinkIdx);
Gruß |
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 |
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]; |
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. |
AW: Excel.Interop OLE -> Problem beim Hyperlink lesen
Zitat:
Delphi-Quellcode:
Mit AHypLink.Address müsstest du an den Link als String kommen.
var
AHypLink : OleVariant; 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 22:26 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz