L
llw1
Unregistered / Unconfirmed
GUEST, unregistred user!
请问如何象WORD一样画表格和在表内填文字,并能保存和调用。(能否留个QQ交流一个)
这是我的程序:
procedure TForm1.BitBtn1Click(Sender: TObject);
var
NewTable,myRange,Word,do
c:OleVariant;
//, Fields
i:integer;
Align,ShowFirstlevariant;
begin
try
Word:=CreateOleObject('Word.Application');
except
application.MessageBox('Çë°²×°Microsoft Word 2000 »ò¸ü¸ß°æ±¾£¡','¾¯¸æ£¡',mb_ok+mb_iconwarning);
abort;
end;
Word.Visible:=True;
//´´½¨¿ÕÎĵµ£»
Word.Documents.Add();
//½«Ò³Ãæ¸ÄΪ¡°ºáÏò¡±£»
Word.ActiveDocument.PageSetup.Orientation := wdOrientLandscape;
Word.ActiveDocument.PageSetup.LineNumbering.Active:=False;
Word.ActiveDocument.PageSetup.Orientation := wdOrientLandscape;
Word.ActiveDocument.PageSetup.TopMargin := 2/0.035;
Word.ActiveDocument.PageSetup.BottomMargin := 2/0.035;
Word.ActiveDocument.PageSetup.LeftMargin := 2/0.035;
Word.ActiveDocument.PageSetup.RightMargin := 2/0.035;
Word.ActiveDocument.PageSetup.Gutter := 0;
Word.ActiveDocument.PageSetup.HeaderDistance := 1.2/0.035;
Word.ActiveDocument.PageSetup.FooterDistance := 1.5/0.035;
Word.ActiveDocument.PageSetup.PageWidth := 29.7/0.035;
Word.ActiveDocument.PageSetup.PageHeight := 21/0.035;
Word.ActiveDocument.PageSetup.FirstPageTray := wdPrinterDefaultBin;
Word.ActiveDocument.PageSetup.OtherPagesTray := wdPrinterDefaultBin;
Word.ActiveDocument.PageSetup.SectionStart := wdSectionNewPage;
Word.ActiveDocument.PageSetup.OddAndEvenPagesHeaderFooter := False;
Word.ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter := False;
Word.ActiveDocument.PageSetup.VerticalAlignment := wdAlignVerticalTop;
Word.ActiveDocument.PageSetup.SuppressEndnotes := False;
Word.ActiveDocument.PageSetup.MirrorMargins := False;
Word.ActiveDocument.PageSetup.TwoPagesOnOne := False;
Word.ActiveDocument.PageSetup.GutterPos := wdGutterPosLeft;
Word.ActiveDocument.PageSetup.LayoutMode := wdLayoutModeLineGrid;
do
c := Word.ActiveDocument;
//дÈëҳüҳ½Å
//дÈëҳüҳ½Å
If word.ActiveWindow.View.SplitSpecial <> wdPaneNone then
begin
word.ActiveWindow.Panes(2).Close;
end;
If (word.ActiveWindow.ActivePane.View.Type=wdNormalView)
Or (word.ActiveWindow.ActivePane.View.Type=wdOutlineView) then
begin
word.ActiveWindow.ActivePane.View.Type:=wdPrintView;
end;
word.ActiveWindow.ActivePane.View.SeekView := wdSeekCurrentPageHeader;
Word.Selection.Font.NameFarEast:='&Euml;&Icirc;&Igrave;&aring;';
Word.Selection.Font.NameAscii:='Times New Roman';
Word.Selection.Font.NameOther:='Times New Roman';
Word.Selection.Font.Name:='Times New Roman';
Word.Selection.Font.Size:=9;
Word.Selection.Font.Bold:=false;
Word.Selection.Font.Italic:=wdToggle;
Word.Selection.TypeText(Text:='<< &Ccedil;&iquest;&Auml;&Ocirc;&sup1;¤&sup3;&Igrave;&Ograve;&micro;&Icirc;&ntilde;&Ntilde;&micro;&Aacute;·&Iuml;&micro;&Iacute;&sup3;
>>');
word.Application.Selection.ParagraphFormat.Alignment := wdAlignParagraphRight;
Align:=wdAlignPageNumberCenter;
ShowFirst:=True;
Word.ActiveDocument.Sections.Item(1).Footers.Item(1).PageNumbers.Add(Align,ShowFirst);
Word.ActiveWindow.ActivePane.View.SeekView := wdSeekMainDocument;
//&ETH;&acute;&Egrave;&euml;±ê&Igrave;&acirc;&pound;&raquo;
Word.Selection.ParagraphFormat.Alignment:=wdAlignParagraphCenter;
Word.Selection.Font.NameFarEast:='&Euml;&Icirc;&Igrave;&aring;';
Word.Selection.Font.NameAscii:='Times New Roman';
Word.Selection.Font.NameOther:='Times New Roman';
Word.Selection.Font.Name:='Times New Roman';
Word.Selection.Font.Size:=22;
Word.Selection.Font.Bold := true;
Word.Selection.TypeText(Text:='&Ntilde;&micro;&Aacute;·&frac14;&AElig;&raquo;&reg;');
Word.Selection.TypeParagraph;
Word.Selection.ParagraphFormat.Alignment:= wdAlignParagraphJustify;
Word.Selection.Font.NameFarEast:='&Euml;&Icirc;&Igrave;&aring;';
Word.Selection.Font.NameAscii:='Times New Roman';
Word.Selection.Font.NameOther:='Times New Roman';
Word.Selection.Font.Name:='Times New Roman';
Word.Selection.Font.Size:=9;
Word.Selection.Font.Bold := false;
//Word.Selection.Font.Bold:=wdToggle;
Word.Selection.TypeParagraph;
//&raquo;&shy;&sup3;&ouml;&iquest;&Otilde;±í&cedil;&ntilde;&pound;&raquo;
Word.ActiveDocument.Tables.Add(Range:=Word.Selection.Range,
NumRows:=10, //ClientDataSet_tmp.RecordCount+1,
NumColumns:=10,
DefaultTableBehavior:=0,
AutoFitBehavior:=0);
//&ordm;&Iuml;&sup2;&cent;±í&cedil;&ntilde;
word.Selection.MoveDown(wdLine,1,wdExtend);
word.Selection.Cells.Merge;
word.Selection.MoveRight(1,1,wdMove);
word.Selection.MoveRight(1,5,wdExtend);
word.Selection.Cells.Merge;
word.Selection.MoveRight(2,1,wdMove);
word.Selection.MoveDown(wdLine,1,wdExtend);
word.Selection.Cells.Merge;
word.Selection.MoveRight(3,1,wdMove);
word.Selection.MoveDown(wdLine,1,wdExtend);
word.Selection.Cells.Merge;
word.Selection.MoveRight(3,1,wdMove);
word.Selection.MoveDown(wdLine,1,wdExtend);
word.Selection.Cells.Merge;
word.Selection.MoveRight(3,1,wdMove);
word.Selection.MoveDown(wdLine,1,wdExtend);
word.Selection.Cells.Merge;
end;
这是我的程序:
procedure TForm1.BitBtn1Click(Sender: TObject);
var
NewTable,myRange,Word,do
c:OleVariant;
//, Fields
i:integer;
Align,ShowFirstlevariant;
begin
try
Word:=CreateOleObject('Word.Application');
except
application.MessageBox('&Ccedil;&euml;°&sup2;×°Microsoft Word 2000 &raquo;ò&cedil;ü&cedil;&szlig;°&aelig;±&frac34;&pound;&iexcl;','&frac34;&macr;&cedil;&aelig;&pound;&iexcl;',mb_ok+mb_iconwarning);
abort;
end;
Word.Visible:=True;
//&acute;&acute;&frac12;¨&iquest;&Otilde;&Icirc;&Auml;&micro;&micro;&pound;&raquo;
Word.Documents.Add();
//&frac12;&laquo;&Ograve;&sup3;&Atilde;&aelig;&cedil;&Auml;&Icirc;&ordf;&iexcl;°&ordm;á&Iuml;ò&iexcl;±&pound;&raquo;
Word.ActiveDocument.PageSetup.Orientation := wdOrientLandscape;
Word.ActiveDocument.PageSetup.LineNumbering.Active:=False;
Word.ActiveDocument.PageSetup.Orientation := wdOrientLandscape;
Word.ActiveDocument.PageSetup.TopMargin := 2/0.035;
Word.ActiveDocument.PageSetup.BottomMargin := 2/0.035;
Word.ActiveDocument.PageSetup.LeftMargin := 2/0.035;
Word.ActiveDocument.PageSetup.RightMargin := 2/0.035;
Word.ActiveDocument.PageSetup.Gutter := 0;
Word.ActiveDocument.PageSetup.HeaderDistance := 1.2/0.035;
Word.ActiveDocument.PageSetup.FooterDistance := 1.5/0.035;
Word.ActiveDocument.PageSetup.PageWidth := 29.7/0.035;
Word.ActiveDocument.PageSetup.PageHeight := 21/0.035;
Word.ActiveDocument.PageSetup.FirstPageTray := wdPrinterDefaultBin;
Word.ActiveDocument.PageSetup.OtherPagesTray := wdPrinterDefaultBin;
Word.ActiveDocument.PageSetup.SectionStart := wdSectionNewPage;
Word.ActiveDocument.PageSetup.OddAndEvenPagesHeaderFooter := False;
Word.ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter := False;
Word.ActiveDocument.PageSetup.VerticalAlignment := wdAlignVerticalTop;
Word.ActiveDocument.PageSetup.SuppressEndnotes := False;
Word.ActiveDocument.PageSetup.MirrorMargins := False;
Word.ActiveDocument.PageSetup.TwoPagesOnOne := False;
Word.ActiveDocument.PageSetup.GutterPos := wdGutterPosLeft;
Word.ActiveDocument.PageSetup.LayoutMode := wdLayoutModeLineGrid;
do
c := Word.ActiveDocument;
//&ETH;&acute;&Egrave;&euml;&Ograve;&sup3;&Atilde;&frac14;&Ograve;&sup3;&frac12;&Aring;
//&ETH;&acute;&Egrave;&euml;&Ograve;&sup3;&Atilde;&frac14;&Ograve;&sup3;&frac12;&Aring;
If word.ActiveWindow.View.SplitSpecial <> wdPaneNone then
begin
word.ActiveWindow.Panes(2).Close;
end;
If (word.ActiveWindow.ActivePane.View.Type=wdNormalView)
Or (word.ActiveWindow.ActivePane.View.Type=wdOutlineView) then
begin
word.ActiveWindow.ActivePane.View.Type:=wdPrintView;
end;
word.ActiveWindow.ActivePane.View.SeekView := wdSeekCurrentPageHeader;
Word.Selection.Font.NameFarEast:='&Euml;&Icirc;&Igrave;&aring;';
Word.Selection.Font.NameAscii:='Times New Roman';
Word.Selection.Font.NameOther:='Times New Roman';
Word.Selection.Font.Name:='Times New Roman';
Word.Selection.Font.Size:=9;
Word.Selection.Font.Bold:=false;
Word.Selection.Font.Italic:=wdToggle;
Word.Selection.TypeText(Text:='<< &Ccedil;&iquest;&Auml;&Ocirc;&sup1;¤&sup3;&Igrave;&Ograve;&micro;&Icirc;&ntilde;&Ntilde;&micro;&Aacute;·&Iuml;&micro;&Iacute;&sup3;
>>');
word.Application.Selection.ParagraphFormat.Alignment := wdAlignParagraphRight;
Align:=wdAlignPageNumberCenter;
ShowFirst:=True;
Word.ActiveDocument.Sections.Item(1).Footers.Item(1).PageNumbers.Add(Align,ShowFirst);
Word.ActiveWindow.ActivePane.View.SeekView := wdSeekMainDocument;
//&ETH;&acute;&Egrave;&euml;±ê&Igrave;&acirc;&pound;&raquo;
Word.Selection.ParagraphFormat.Alignment:=wdAlignParagraphCenter;
Word.Selection.Font.NameFarEast:='&Euml;&Icirc;&Igrave;&aring;';
Word.Selection.Font.NameAscii:='Times New Roman';
Word.Selection.Font.NameOther:='Times New Roman';
Word.Selection.Font.Name:='Times New Roman';
Word.Selection.Font.Size:=22;
Word.Selection.Font.Bold := true;
Word.Selection.TypeText(Text:='&Ntilde;&micro;&Aacute;·&frac14;&AElig;&raquo;&reg;');
Word.Selection.TypeParagraph;
Word.Selection.ParagraphFormat.Alignment:= wdAlignParagraphJustify;
Word.Selection.Font.NameFarEast:='&Euml;&Icirc;&Igrave;&aring;';
Word.Selection.Font.NameAscii:='Times New Roman';
Word.Selection.Font.NameOther:='Times New Roman';
Word.Selection.Font.Name:='Times New Roman';
Word.Selection.Font.Size:=9;
Word.Selection.Font.Bold := false;
//Word.Selection.Font.Bold:=wdToggle;
Word.Selection.TypeParagraph;
//&raquo;&shy;&sup3;&ouml;&iquest;&Otilde;±í&cedil;&ntilde;&pound;&raquo;
Word.ActiveDocument.Tables.Add(Range:=Word.Selection.Range,
NumRows:=10, //ClientDataSet_tmp.RecordCount+1,
NumColumns:=10,
DefaultTableBehavior:=0,
AutoFitBehavior:=0);
//&ordm;&Iuml;&sup2;&cent;±í&cedil;&ntilde;
word.Selection.MoveDown(wdLine,1,wdExtend);
word.Selection.Cells.Merge;
word.Selection.MoveRight(1,1,wdMove);
word.Selection.MoveRight(1,5,wdExtend);
word.Selection.Cells.Merge;
word.Selection.MoveRight(2,1,wdMove);
word.Selection.MoveDown(wdLine,1,wdExtend);
word.Selection.Cells.Merge;
word.Selection.MoveRight(3,1,wdMove);
word.Selection.MoveDown(wdLine,1,wdExtend);
word.Selection.Cells.Merge;
word.Selection.MoveRight(3,1,wdMove);
word.Selection.MoveDown(wdLine,1,wdExtend);
word.Selection.Cells.Merge;
word.Selection.MoveRight(3,1,wdMove);
word.Selection.MoveDown(wdLine,1,wdExtend);
word.Selection.Cells.Merge;
end;