Autor |
Beitrag |
scholei
Beiträge: 24
|
Verfasst: Di 13.09.05 17:34
Hallo,
ich schreibe eine VCL-Formularanwendung für .NET und benutze
Delphi 2005.
Ich habe das Proplem, dass ich kein existierendes Document in Word laden kann. Word ohne Dokument bzw. beim öffnen ein neues Dokument anlegen funktioniert.
Bekomme folgenden Fehler:
[Fehler] Formular.pas(17311): E2250 Es gibt keine überladene Version von 'Open', die man mit diesen Argumenten aufrufen kann
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:
| implementation
{$R *.nfm} uses Microsoft.Office.Interop.Word,System.Reflection;
procedure TFHauptformular.Button1Click(Sender: TObject); var wordapp: Microsoft.Office.Interop.Word.Application; n: System.Object; FileName, NewFile : OleVariant; Mail : MailMerge; Pause : OleVariant;
begin
wordapp:= Microsoft.Office.Interop.Word.Applicationclass.Create;
n:= System.Reflection.Missing.Value;
if (wordapp = nil) then begin ShowMessage('keine Verbindung!'); Exit; end; if OpenDialog1.Execute then FileName:=OpenDialog1.FileName else exit;
wordapp.Documents.Open(FileName,n,n,n,n,n,n,n,n,n,n,n,n,n,n);
wordapp.Visible:= true;
end; |
An was könnte das liegen?
Grüße
scholei
Moderiert von AXMD: Delphi-Tags hinzugefügt.
|
|
AXMD
Beiträge: 4006
Erhaltene Danke: 7
Windows 10 64 bit
C# (Visual Studio 2019 Express)
|
Verfasst: Di 13.09.05 17:37
Sind die vielen n als Parameter Absicht
AXMD
|
|
scholei
Beiträge: 24
|
Verfasst: Di 13.09.05 17:50
wenn ein Parameter mehr ist kommt zu viele Parameter
sonst kommt immer der gleiche Fehler auch wenn ich nur FileName angebe
Gruß
sven
|
|
Marauder
Beiträge: 72
|
Verfasst: Di 13.09.05 18:15
Die n's gehören so, das sind missing Parameter..
So funktioniert's bei mir:
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20:
| Procedure PrintErgebnis(sSatz:String); var WordApp : Microsoft.Office.Interop.Word.Application; n,o0,o1,o2,o3 : System.&Object; begin wordapp := microsoft.Office.Interop.Word.ApplicationClass.Create ; n := system.Reflection.Missing.Value ; if (wordapp = nil) then begin messagebox.Show('Fehler bei Wordinit !'); end; o0 := sVorlagen+'\Ergebnis.doc'; o1 :='Text2'; o2 :='Text3'; wordapp.Visible := true; wordapp.Documents.Open (o0,n,n,n,n,n,n,n,n,n,n,n,n,n,n); wordapp.ActiveDocument.FormFields.Item [o1].Result := sSatz; wordapp.ActiveDocument.FormFields.Item [o2].Result := 'Testtext 2 für Ergebnisausdruck aus Delphi'; end; |
Gruß
|
|
scholei
Beiträge: 24
|
Verfasst: Di 13.09.05 19:17
super soweit funktioniert es ja ganz gut.
beim öffnen kommt jetzt noch ein Fenster, siehe Datei.
Wie bekomme ich das jetz noch weg.
Ich würde gene noch Bookmarks füllen, kannst du mir vielleicht noch sagen wie das funktioniert?
Gruß
Sven
Einloggen, um Attachments anzusehen!
|
|
AXMD
Beiträge: 4006
Erhaltene Danke: 7
Windows 10 64 bit
C# (Visual Studio 2019 Express)
|
Verfasst: Di 13.09.05 19:21
Hast du die Datei in Word geöffnet? Ich mein bevor das Programm startet.
AXMD
|
|
scholei
Beiträge: 24
|
Verfasst: Di 13.09.05 19:26
nein hab das schon kontrolliert
Gruß
sven
|
|
Marauder
Beiträge: 72
|
Verfasst: Di 13.09.05 19:52
Also DAS Fenster hab ich jetzt noch nie gesehen...
Du hast das Dokument nicht zufällig noch wo anders offen?
Blödsinn... hast Du ja grade verneint... puhh.. keine Ahnung, woran das liegt...
|
|
scholei
Beiträge: 24
|
Verfasst: Di 13.09.05 20:26
das Proplem mit dem fenster hat sich wie von Geisterhand von selbst gelöst. keine Ahnung.
ich hab noch das Proplem mit füllen von Textmarken in Word.
hab noch keine Ahnung wie das Funktioniert.
Weist du da möglicherweise eine Lösung?
Gruß
sven
|
|
Marauder
Beiträge: 72
|
Verfasst: Di 13.09.05 20:40
was willste denn genau machen? Textmarken sagt mir jetzt so gar nix...
|
|
scholei
Beiträge: 24
|
Verfasst: Mi 14.09.05 12:08
Ich will Dokument Vorlagen erstellen.
Man kann in Word Textmarken einfügen (so ne Art Platzhalter).
Diese will ich aus Delphi heraus mit Daten füllen.
In Delpi gibt es 'wordapp.ActiveDocument.Bookmarks' die man dafür verwenden kann. Ich bin allerdings noch nicht so recht dahinter gestiegen wie man diese richtig einsetzt.
Gruß
Sven
|
|
scholei
Beiträge: 24
|
Verfasst: Mi 14.09.05 16:19
habe das mit dem Textmarke´n mittlerweise in griff
hier ein Beispiel, vielleicht hilft´s ja Euch auch weiter:
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:
| procedure TFHauptformular.ButtonClick(Sender: TObject); var wordapp: Microsoft.Office.Interop.Word.Application;
FileName,NewFile: TObject; n : System.&Object; BookmarkKundeNR,BookmarkName,BookmarkVorname:System.&Object;
begin wordapp:=Microsoft.Office.Interop.Word.Applicationclass.Create;
n:= System.Reflection.Missing.Value;
if (wordapp = nil) then begin ShowMessage('keine Verbindung!'); Exit; end;
if OpenDialog1.Execute then begin FileName:=OpenDialog1.FileName; end else begin exit; end;
wordapp.Visible:= true; wordapp.Documents.Open(FileName,n,n,n,n,n,n,n,n,n,n,n,n,n,n);
BookmarkKundeNR:= 'NR'; BookmarkName := 'Name'; BookmarkVorname := 'Vorname';
if wordapp.ActiveDocument.Bookmarks.Exists('NR') then begin wordapp.ActiveDocument.Bookmarks.Item[BookmarkNR].Select; wordapp.Selection.TypeText(Trim(ENummer.Text)); end;
if wordapp.ActiveDocument.Bookmarks.Exists('Name') then begin wordapp.ActiveDocument.Bookmarks.Item[BookmarkName].Select; wordapp.Selection.TypeText(Trim(EName.Text)); end;
if wordapp.ActiveDocument.Bookmarks.Exists('Vorname') then begin wordapp.ActiveDocument.Bookmarks.Item[BookmarkVorname].Select; wordapp.Selection.TypeText(Trim(EVorname.Text)); end; end; |
Gruß
Sven
Moderiert von raziel: Delphi-Tags hinzugefügt.
|
|
|