Autor Beitrag
bis11
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1247
Erhaltene Danke: 2

Apple Mac OSX 10.11

BeitragVerfasst: Di 03.09.02 11:19 
Hallo Leute,

wie kann ich ein leeres Dokument öffnen in Word über die Automation von Delphi ? Bedingung ist, es muß auf Office 97,2000 und XP laufen.

Ich habe schon mal folgendes versucht :

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
uses
  ComObj, ComCtrls;


var
  WordApp : OleVariant;
begin
  WordApp := CreateOleObject('Word.Application');   
  screen.Cursor:=crHourglass;                                  
  try                                                                        
    WordApp:=GetActiveOleObject('Word.Application');
  except    
    try      
      WordApp:=CreateOleObject('Word.Application');
    except                                                          
      ShowMessage('Microsoft Word kann nicht starten.');
      screen.cursor:=crDefault;
      exit;
    end;
  end;
  WordApp.visible:=true;
  WordApp.Document.AddOld('EmptyParam','EmptyParam');


Beim Ausführen kommt dann folgende Fehlermeldung :

Im Projekt xxxx ist eine Exception der Klasse EOleSysError aufgetreten. Meldung:
'Typkonflikt'. Prozeß wurde angehalten. Mit Einzelne Anweisung oder Start
fortsetzen.

Was mache ich verkehrt ? Testumgebung : Win200 mit Office XP

Ich bin für jede Hilfe dankbar.
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Di 03.09.02 11:38 
Wahrscheinlich heisst es:

ausblenden Quelltext
1:
WordApp.Documents.AddOld('EmptyParam','EmptyParam');					



Wobei das auch genügen sollte:

ausblenden Quelltext
1:
WordApp.Documents.Add;					
bis11 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1247
Erhaltene Danke: 2

Apple Mac OSX 10.11

BeitragVerfasst: Di 03.09.02 11:46 
Hi Toms,

also erstmal Danke für Deine schnelle Antwort. Die Zeile
Zitat:
WordApp.Documents.AddOld('EmptyParam','EmptyParam');

Hat auch nicht geholfen. Aber mit :
Zitat:
WordApp.Documents.Add;
hat es funktioniert.
bis11 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1247
Erhaltene Danke: 2

Apple Mac OSX 10.11

BeitragVerfasst: Di 03.09.02 12:38 
Könntest Du mir vielleicht nochmal helfen ?

Ich habe folgenenden VB-Code :
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
ActiveDocument.MailMerge.OpenDataSource Name := "D:\Temp\REPORT.xls",
        ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True,
        AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="",
        WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False,
        Format:='wdOpenFormatAuto', Connection:="Gesamtes Tabellenblatt",
        SQLStatement:="", SQLStatement1:="", SubType:=wdMergeSubTypeOther
CommandBars("Mail Merge").Visible := true


In Delphi so geschrieben :

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
  WordApp.ActiveDocument.MailMerge.OpenDataSource(FileName := AFileName,
        ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True,
        AddToRecentFiles:=False, PasswordDocument:='', PasswordTemplate:='',
        WritePasswordDocument:='', WritePasswordTemplate:='', Revert:=False,
        Format:='wdOpenFormatAuto', Connection:='Gesamtes Tabellenblatt',
        SQLStatement:='', SQLStatement1:='', SubType:='wdMergeSubTypeOther');
  WordApp.CommandBars('Mail Merge').Visible := true;


Was habe ich verkehrt gemacht ? Achso, in AFileName weise ich vorher noch so den Wert zu :

AFileName := 'D:\Temp\REPORT.XLS';