Autor Beitrag
nooby
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44

Win XP Pro.
D7
BeitragVerfasst: Di 05.08.03 13:43 
Hallo,
will aus Delphi ein Word-Dokument erstellen lassen. Habe dafür eine Musterseite erstellt und versucht den VBA-Cod in Delphi zu benutzen. Leider funktioniert das bei einigen Befehlen (die auskommentierten) nicht. Wer kann weiterhelfen?

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:
//    Word.Selection.PageSetup.TopMargin := CentimetersToPoints(5.71);
    Word.Selection.TypeText (Text:='Name, Vorname');
    Word.Selection.TypeParagraph;
    Word.Selection.TypeText (Text:='Anschrift');
    Word.Selection.TypeParagraph;
    Word.Selection.TypeParagraph;
    Word.Selection.TypeText (Text:='PLZ Ort');
    Word.Selection.TypeParagraph;
    Word.Selection.TypeParagraph;
    Word.Selection.TypeParagraph;
//    Word.Selection.ParagraphFormat.Alignment := wdAlignParagraphRight;
    Word.Selection.TypeText (Text:='Datum');
    Word.Selection.TypeParagraph;
//    Word.Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft;
    Word.Selection.TypeParagraph;
    Word.Selection.TypeText (Text:='Art / Nr');
    Word.Selection.TypeParagraph;
    Word.Selection.TypeParagraph;
    Word.Selection.TypeText (Text:='blablabla');
    Word.Selection.TypeParagraph;
    Word.Selection.TypeParagraph;
    Word.Selection.TypeParagraph;
    // Erstelle eine Tabelle in Word!
//    Word.Selection.Tables.Add (Range:=Word.Selection.Range, NumRows:=2, NumColumns:=5, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= wdAutoFitFixed);
    Word.Selection.TypeText (Text:='Spalte1');
//    Word.Selection.MoveRight (Unit:=wdCell);
    Word.Selection.TypeText (Text:='Spalte2');
//    Word.Selection.MoveRight (Unit:=wdCell);
    Word.Selection.TypeText (Text:='Spalte3');
//    Word.Selection.MoveRight (Unit:=wdCell);
    Word.Selection.TypeText (Text:='Spalte4');
//    Word.Selection.MoveRight (Unit:=wdCell);
    Word.Selection.TypeText (Text:='Spalte5');
//    Word.Selection.MoveRight (Unit:=wdCell);
    Word.Selection.TypeText (Text:='1');
//    Word.Selection.MoveRight (Unit:=wdCell);
    Word.Selection.TypeText (Text:='2');
//    Word.Selection.MoveRight (Unit:=wdCell);
    Word.Selection.TypeText (Text:='3');
//    Word.Selection.MoveRight (Unit:=wdCell);
    Word.Selection.TypeText (Text:='4');
//    Word.Selection.MoveRight (Unit:=wdCell);
    Word.Selection.TypeText (Text:='5');


Moderiert von user profile icontommie-lie: Delphi-Tags hinzugefügt
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Di 05.08.03 14:28 
Hallo

so auf die schnelle: (kann grad nicht nachguggn)

nutzt du die Serverkompos?

Zitat:

Word.Selection.PageSetup.TopMargin := CentimetersToPoints(5.71);

centimeterstopoint ist keine funktion von Delphi, sondern von Wordapplication selbst. versuchs mal mit word.centimeters ...

Zitat:

Word.Selection.ParagraphFormat.Alignment := wdAlignParagraphRight;

sollte gehen
Zitat:

Word.Selection.MoveRight (Unit:=wdCell);

schreib das anders
ausblenden Quelltext
1:
Word.Selection.MoveRight (wdCell);					

wenn Delphi rummeckert, geh über ien zwischenvar
ausblenden Quelltext
1:
2:
3:
4:
Var dummy:olevariant;
...
dummy:=wdCell;
Word.Selection.MoveRight (dummy);


für die geschichte mit tables gilt das gleiche, guug dir in der Word97.pas oder mit der Codevervollständigung und in der VB-Hilfe die genauen parameter an, macnche sind optional, dann reicht meist ein emptyparam als parameter.

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
nooby Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44

Win XP Pro.
D7
BeitragVerfasst: Di 05.08.03 20:34 
Hi, habe jetzt mal die word2000.pas mit eingebunden und es läuft. Müßte die nicht über die ComObj automat. eingebunden werden?
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Di 05.08.03 20:41 
nein, wenn du dir die sourcen anguugst, ist es über umwege genau anders rum :wink:

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
nooby Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44

Win XP Pro.
D7
BeitragVerfasst: Di 05.08.03 20:49 
Naja, in alles Quellen die ich gefunden hatte, war nur die ComObj angegeben. Jetzt geht es ja, und für die Zukunft weis ich bescheid. Danke Dir.
nooby Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44

Win XP Pro.
D7
BeitragVerfasst: Mi 06.08.03 07:27 
Noch eine Frage:

Die Option .borders meckert er an. Hast Du da auch eine Alternative, ich finde keine.


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
    //lösche Rahmen
    Word.Selection.Tables.Borders(wdBorderLeft).LineStyle := wdLineStyleNone;
    Word.Selection.Tables.Borders(wdBorderRight).LineStyle := wdLineStyleNone;
    Word.Selection.Tables.Borders(wdBorderTop).LineStyle := wdLineStyleNone;
    Word.Selection.Tables.Borders(wdBorderBottom).LineStyle := wdLineStyleNone;
    Word.Selection.Tables.Borders(wdBorderHorizontal).LineStyle := wdLineStyleNone;
    Word.Selection.Tables.Borders(wdBorderVertical).LineStyle := wdLineStyleNone;
    Word.Selection.Tables.Borders(wdBorderDiagonalDown).LineStyle := wdLineStyleNone;
    Word.Selection.Tables.Borders(wdBorderDiagonalUp).LineStyle := wdLineStyleNone;
    Word.Selection.Tables.Borders.Shadow := False;
     Word.Selection.Tables.Options.DefaultBorderLineStyle := wdLineStyleSingle;
     Word.Selection.Tables.Options.DefaultBorderLineWidth := wdLineWidth050pt;
     Word.Selection.Tables.Options.DefaultBorderColor := wdColorAutomatic;


Moderiert von user profile iconKlabautermann: Delphi-Tags hinzugefügt & BBCode aktiviert.
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Mi 06.08.03 07:44 
ausblenden Delphi-Quelltext
1:
  WordApplication1.Selection.Tables.Item(1).Borders.Item(wdBorderLeft).LineStyle := blabla					

ist wie in Delphi sonst auch, geh über die items.
die 1 bei Tables ist dann entsprechend die 1. Tabelle.

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
nooby Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44

Win XP Pro.
D7
BeitragVerfasst: Mi 06.08.03 10:29 
Danke