Autor Beitrag
cscp
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 49



BeitragVerfasst: Fr 21.01.05 23:34 
Hallo,
hab mir eine Prozedur geschrieben die was in Word exportiert... mein Problem nun: Ich hab die Prozedur in ne DLL ausgelagert und jetzt kommt immer wenn ich word.free ausführe eine Fehlermeldung... im Hauptprogramm jedoch funktionierts prächtig... Weiss jemand rat?

hier der code meiner dll...

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
library oleLibrary;

{ Wichtiger Hinweis zur DLL-Speicherverwaltung: ShareMem muss sich in der
  ersten Unit der unit-Klausel der Bibliothek und des Projekts befinden (Projekt-
  Quelltext anzeigen), falls die DLL Prozeduren oder Funktionen exportiert, die
  Strings als Parameter oder Funktionsergebnisse übergeben. Das gilt für alle
  Strings, die von oder an die DLL übergeben werden -- sogar für diejenigen, die
  sich in Records und Klassen befinden. Sharemem ist die Schnittstellen-Unit zur
  Verwaltungs-DLL für gemeinsame Speicherzugriffe, BORLNDMM.DLL.
  Um die Verwendung von BORLNDMM.DLL zu vermeiden, können Sie String-
  Informationen als PChar- oder ShortString-Parameter übergeben. }

  

uses
  ShareMem,
  SysUtils,
  ComObj,
  Dialogs,
  DBTables,
  Classes;

var
  wordApplication: Variant;
  workdir: String;

{$R *.res}
procedure CreateInitOle;
begin
  try
    wordApplication:= CreateOleObject('Word.Application');
    wordApplication.visible:=true;
    wordApplication.documents.add;
    wordApplication.selection.font.name:='Verdana';
    wordApplication.selection.font.size:=10;
    wordApplication.selection.font.bold:=true;
    wordApplication.selection.paragraphFormat.Alignment:=0;
    wordApplication.selection.typetext(Text:='Bibliotheca - Listenexport');
    wordApplication.selection.typeParagraph;
    wordApplication.selection.font.bold:=false;
  except
    MessageDlg('Konnte Word nicht starten!!', mtError, [mbCancel], 0);
    Exit;
  end;
end;

procedure exportLendings;
var wrdtbl: TTable;
begin

  //Ole Objekt erstellen und alle Formatierungen vornehmen
  CreateInitOle;

  wordApplication.selection.typetext(Text:='Stand ('+DateToStr(now)+' / '+TimeToStr(now)+')');
  wordApplication.selection.typeParagraph;
  wordApplication.selection.typeParagraph;
  wordApplication.selection.typeParagraph;
  wrdtbl:=TTable.Create(nil);
  GetDir(0,workdir);
  wrdtbl.TableName:=workdir+'\database\lendings.db';
  wrdtbl.active:=true;
  wrdtbl.Open;
  wrdtbl.first;
  while not wrdtbl.eof do begin
    wordApplication.selection.typetext(Text:=IntToStr(wrdtbl.FieldValues['MemberId'])+' leiht aus '+IntToStr(wrdtbl.FieldValues['BookId'])+' // Ausgabedatum: '+DateToStr(wrdtbl.FieldValues['Date']));
    wordApplication.selection.typeParagraph;
    wrdtbl.next;
  end;
  wrdtbl.close;
  wrdtbl.Active:=false;
  wrdtbl.Free;

  wordApplication.free;
end;

exports
  exportLendings;
  
begin
end.
bis11
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1247
Erhaltene Danke: 2

Apple Mac OSX 10.11

BeitragVerfasst: So 23.01.05 14:38 
Ich muss nochmal nachschauen, aber vielleicht hilft Dir dieser Tipp, hast Du mal nachgeschaut ob Du vielleicht nicht unter Uses eine Unit vergessen hast ? Probiere mal diese beiden Units in der Uses Klausel aus OleServer, WordXP. Wobei die Unit WordXP abweichen kann, genachdem, welches Office Du installiert hast.
cscp Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 49



BeitragVerfasst: So 23.01.05 15:10 
hmm wenn ich das wordapplication.free weglasse und das programm nicht in delphi laufen lasse dann läufts problemlos...
in delphi kommt aber: es traten zu viele exceptions auf... das macht mir angst... noch irgendne idee?
ase
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 203

Gentoo, Windows 9X, ME, 2k, NT, XP
Delphi 7 Prof., PHP 5 (Eclipse 3 SDK)
BeitragVerfasst: Do 27.01.05 15:17 
Nimm mal die Unit ShareMem raus.


-EN

_________________
-EN