Autor Beitrag
lexmy3
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140

WIN 2000 Prof. + Office 2000
Delphi 5 Enterprise
BeitragVerfasst: Do 09.03.06 16:59 
Hey Allesamt,

Ich bins wieder, fühle mich wie daheim hier :lol:

Habe wieder hier eins von meinen Problemen und zwar ich möchte Eine ExcelVorlage ansprechen und da was in die Kopfzeile einfügen.

Habe nichts weiter finden können.

Hier mein Schnipsel:
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:
procedure TForm1.Button2Click(Sender: TObject);
var
   flcid: DWord;
   ExcelVorlage : OleVariant;
   sValue : String;
begin
     try
     ExcelVorlage := ('C:\ExcelEnglish\Condition.xlt'); // Pfad angeben!!!

     flcid:=GetUserDefaultLCID;
     ExcelApplication1.Connect;
     ExcelApplication1.Visible[flcid]:=true;
     ExcelApplication1.UserControl:=true;

     ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks.Add(ExcelVorlage,flcid));

     ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Sheets.Item[1as ExcelWorkSheet);
     sValue:=ExcelWorksheet1.Range['B1','B1'].Value;

    //Kopzeile anzeigen und Text einfügen
//?????????????????????????????????????????????

    ExcelWorksheet1.Disconnect;
Finally

     ExcelApplication1.Disconnect;
     Application.Terminate;
         end;
              end;

end.


wäre cool wenn hier mal wieder einer nen Schups geben könnte.

mfg

lexmy3


Zuletzt bearbeitet von lexmy3 am Fr 10.03.06 11:14, insgesamt 1-mal bearbeitet
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: Do 09.03.06 17:18 
Hallo

das geht im Excel über activesheet bzw worksheet->pagesetup dort gibt es left-,right- und centerheader.
Zeichne dir einfach ein makro in excel auf, dann siehts du das.

Mfg Frank

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

WIN 2000 Prof. + Office 2000
Delphi 5 Enterprise
BeitragVerfasst: Do 09.03.06 18:02 
hey habe jetzt ein makro aufgezeichnet, jedoch ist da ganz schön viel Zeug Dabei.

Braucht mann es alles auch bei Delphi??

Das mit Übersetzen ins Delphi ist nicht so einfach.
Habe ich schon bei Word kennengelernt.

ausblenden volle Höhe 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:
Sub Makro1()
'
' Makro1 Makro
' Makro am 09.03.2006 von lexmy3 aufgezeichnet
'

'
    With ActiveSheet.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
    ActiveSheet.PageSetup.PrintArea = ""
    With ActiveSheet.PageSetup
        .LeftHeader = "Location"
        .CenterHeader = ""
        .RightHeader = "Datum"
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.787401575)
        .RightMargin = Application.InchesToPoints(0.787401575)
        .TopMargin = Application.InchesToPoints(0.984251969)
        .BottomMargin = Application.InchesToPoints(0.984251969)
        .HeaderMargin = Application.InchesToPoints(0.4921259845)
        .FooterMargin = Application.InchesToPoints(0.4921259845)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .PrintQuality = 600
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlPortrait
        .Draft = False
        .PaperSize = xlPaperA4
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = 100
    End With
End Sub


Moderiert von user profile iconChristian S.: Delphi- durch Code-Tags ersetzt. Dass ich das noch erleben darf :mrgreen:
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: Do 09.03.06 20:01 
user profile iconlexmy3 hat folgendes geschrieben:

Braucht mann es alles auch bei Delphi??

Ausprobieren?
Da das pagesetup nur eigenschaften hat, reicht die Verwednung von .LeftHeader, .CenterHeader .RightHeader. es wäre etwas anderes, wenn es so aussähe (als procedure mit vielen Parametern:
ausblenden Delphi-Quelltext
1:
setpagesetup(LeftHeader,CenterHeader,RightHeader, viele andere ...)					

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

WIN 2000 Prof. + Office 2000
Delphi 5 Enterprise
BeitragVerfasst: Fr 10.03.06 10:33 
Moin,

Habe diesen Code in VB(Excel) und möchte dieses aus Delphi übergeben.

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
Sub Kopfzeile_ansprechen()

With ActiveSheet.PageSetup
.LeftHeader = "TEST"
.CenterHeader = "Test1"
.RightHeader = "Test2"
.LeftFooter = "TEst3"
.CenterFooter = "Test4"
.RightFooter = "Test5"
End With
End Sub


Mit dem Übersetzen ins Delphisch ist für mich als Amateur nicht so einfach, denn ich probiere aber auch mit Codevervollständigung klappt es nicht so.

In Word habe ich es so gemacht:
ausblenden Delphi-Quelltext
1:
2:
WordApplication1.ActiveWindow.ActivePane.View.SeekView := wdSeekCurrentPageHeader;
WordApplication1.Selection.TypeText( Edit1.Text );


Aber in Excel klappt es mit diesm Muster nicht.

Habe es so angefangen: Und komme nicht wirklich weeiter.

ausblenden Delphi-Quelltext
1:
ExcelWorksheet1.Pagesetup.LeftHeader.TypeText( Edit1.Text );					


Aber:[Fehler] Unit1.pas(84): Record, Objekt oder Klassentyp erforderlich

Bedarf unbedingt Hilfe denn dies muss bis MONTAG fertig werden.

mfg

Lexmy3
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: Fr 10.03.06 10:44 
Hallo

für was hälst du in VB ein
.LeftHeader = "TEST"??
warum zum Geier machst du dann ein typetext dahinter?

ohne es probiert zu haben:
ausblenden Delphi-Quelltext
1:
ExcelWorksheet1.Pagesetup.LeftHeader:=Edit1.text					


Mfg Frank

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

WIN 2000 Prof. + Office 2000
Delphi 5 Enterprise
BeitragVerfasst: Fr 10.03.06 11:12 
OK OK :roll: , hast ja Recht bin wohl schon im WE bzw. bin ja auch nur ein Hobbyprogramierer.

Vielen Dank für deine Unterstützung Keldorn, Du hast mir echt viel geholfen in diesem Forum.
Nur weiter so und du kommst in den Himmel. :flehan:

Jetz klapptt es so wie ich es möchte.

hier die Unit:
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:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Word97, OleServer, StdCtrls, Excel97, ComCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    WordApplication1: TWordApplication;
    WordDocument1: TWordDocument;
    Edit1: TEdit;
    Label1: TLabel;
    Edit2: TEdit;
    Button2: TButton;
    Label2: TLabel;
    ExcelApplication1: TExcelApplication;
    ExcelWorksheet1: TExcelWorksheet;
    ExcelWorkbook1: TExcelWorkbook;
    DateTimePicker1: TDateTimePicker;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}
 // ABER NUR WENN -WORD- SCHON OFFEN IST////////////////////////////////////////
procedure TForm1.Button1Click(Sender: TObject);

begin  
  //eine Wordapplication+WordDocument auf die Form, alle einstellugen so lassen
  WordApplication1.Connect;
  try  
    //neues Dokument hinzufügen und zu diesem verbinden
    WordDocument1.ConnectTo(WordApplication1.Documents.Add(EmptyParam,EmptyParam));

    //Kopzeile anzeigen und Text einfügen
    WordApplication1.ActiveWindow.ActivePane.View.SeekView := wdSeekCurrentPageHeader;

    WordApplication1.Selection.TypeText( Edit1.Text );

    //text zentrieren
    WordApplication1.Selection.ParagraphFormat.Alignment := wdAlignParagraphCenter;

    //wieder zurück zum Dokument
    WordApplication1.ActiveWindow.ActivePane.View.SeekView := wdSeekMainDocument;

  finally  
    WordApplication1.Disconnect;  
  end;  
end;

procedure TForm1.Button2Click(Sender: TObject);
var
   flcid: DWord;
   ExcelVorlage : OleVariant;
   sValue : String;
begin
     try
     ExcelVorlage := ('C:\ExcelEnglish\Condition.xlt'); // Pfad angeben!!!

     flcid:=GetUserDefaultLCID;
     ExcelApplication1.Connect;
     ExcelApplication1.Visible[flcid]:=true;
     ExcelApplication1.UserControl:=true;

     ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks.Add(ExcelVorlage,flcid));

     ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Sheets.Item[1as ExcelWorkSheet);
     sValue:=ExcelWorksheet1.Range['B1','B1'].Value;

    //Kopzeile ansprechen und Text einfügen
     ExcelWorksheet1.PageSetup.LeftHeader  := Edit2.text ;
     ExcelWorksheet1.PageSetup.RightHeader := (DateToStr(DateTimePicker1.Date));

    ExcelWorksheet1.Disconnect;
Finally

     ExcelApplication1.Disconnect;
     Application.Terminate;
         end;
              end;

end.


mfg

Lexmy3