Форум: "Corba";
Текущий архив: 2005.07.25;
Скачать: [xml.tar.bz2];
ВнизАвтоматизация Office Найти похожие ветки
← →
inkarik © (2004-10-18 12:43) [0]Всем привет! У меня проблема:
1)открыл HTML в ворде и сохранил, как *.DOC
2)Выделил содержимое первой страницы и вырезал
3)Создал новый документ и "Paste"
4)Сохранил, закрыл и перешёл на пункт (2)
Теперь вопрос:
Как узнать количество страниц в активном документе?
Как послать сообщение с вложением (активным вордовским документом) из Ворда (Пожалуста! если можете распешите подрабно)?
← →
inkarik © (2004-10-18 15:01) [1]Всем привет! У меня проблема:
1)открыл HTML в ворде и сохранил, как *.DOC
2)Выделил содержимое первой страницы и вырезал
3)Создал новый документ и "Paste"
4)Сохранил, закрыл и перешёл на пункт (2)
Теперь вопрос:
Как узнать количество страниц в активном документе?
Как послать сообщение с вложением (активным вордовским документом) из Ворда (Пожалуста! если можете распешите подрабно)?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Word_TLB, word97, word2000, comobj, OleServer,
Outlook2000;
type
TForm1 = class(TForm)
Button1: TButton;
WordApplication1: TWordApplication;
WordDocument1: TWordDocument;
Label1: TLabel;
OutlookApplication1: TOutlookApplication;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses StrUtils;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var FileName : olevariant;
i : integer;
ConfirmConversions, ReadOnly, AddToRecentFiles,
PasswordDocument,PasswordTemplate, Revert, ritePasswordDocument,
WritePasswordTemplate, Format ,FileFormat, LockComments,Password, WritePassword,ReadOnlyRecommended, EmbedTrueTypeFonts, SaveNativePictureFormat,SaveFormsData, SaveAsAOCELetter : OleVariant;
unit_, counts, Extends, LinkToFile,SaveWithDocument : OleVariant;
PageSetups : PageSetup;
What, Which, Name , DocumentType : OleVariant;
begin
try
WordApplication1.AutoConnect:=true;
WordApplication1.Connect;
WordApplication1.Visible:=true;
WordApplication1.ChangeFileOpenDirectory("i:\work\sendmail\3\");
filename:="uved_org.htm"; ConfirmConversions:=False;
ReadOnly:=False; AddToRecentFiles:=False;
PasswordDocument:=""; PasswordTemplate:="";
Revert:=False; WritePasswordDocument:="";
WritePasswordTemplate:=""; Format:=wdOpenFormatAuto;
WordApplication1.Documents.Open(filename,
ConfirmConversions, ReadOnly, AddToRecentFiles, PasswordDocument,
PasswordTemplate, Revert, WritePasswordDocument, WritePasswordTemplate, Format,EmptyParam,EmptyParam);
FileName:="uved_org.doc";
FileFormat:=wdFormatDocument; LockComments:=False;
Password:=""; AddToRecentFiles:= True; WritePassword:="";
ReadOnlyRecommended:=False; EmbedTrueTypeFonts:=False;
SaveNativePictureFormat:=False; SaveFormsData:=False;
SaveAsAOCELetter:=False;
if WordApplication1.ActiveDocument.ActiveWindow.View.SplitSpecial= wdpanenone then
WordApplication1.ActiveDocument.ActiveWindow.ActivePane.View.type_:=wdPrintView
else WordApplication1.ActiveDocument.ActiveWindow.View.type_:=wdPrintView;
WordApplication1.ChangeFileOpenDirectory("i:\work\sendmail\1\");
WordApplication1.ActiveDocument.SaveAs
(FileName, FileFormat, LockComments, Password, AddToRecentFiles,
WritePassword, ReadOnlyRecommended, EmbedTrueTypeFonts,
SaveNativePictureFormat, SaveFormsData, SaveAsAOCELetter);
PageSetups:=WordApplication1.ActiveDocument.PageSetup;
for i:=1 to 12 do begin
What:=wdGoToPage;
Which:=wdGoToFirst;
Name:="1";
WordApplication1.Selection.GoTo_(What, Which, EmptyParam, Name);
WordApplication1.Selection.Find.ClearFormatting;
With WordApplication1.Selection.Find do begin
Text:=""; Replacement.Text:="";
Forward := True; Wrap := wdFindContinue;
Format := False; MatchCase := False;
MatchWholeWord := False; MatchWildcards := False;
MatchSoundsLike := False; MatchAllWordForms := False;
End;
Unit_:=wdStory;
WordApplication1.Selection.HomeKey(unit_ , EmptyParam);
WordApplication1.Browser.Next;
unit_:=wdLine; counts:=1; Extends:=wdExtend;
WordApplication1.Selection.MoveUp(unit_,counts, EmptyParam);
unit_:=wdStory; Extends:=wdExtend;
WordApplication1.Selection.HomeKey(unit_,Extends);
WordApplication1.Selection.Cut;
DocumentType:=wdNewBlankDocument;
WordApplication1.Documents.Add(EmptyParam,EmptyParam,DocumentType,EmptyParam);
WordApplication1.ActiveDocument.Activate;
WordApplication1.ActiveDocument.PageSetup:=PageSetups;
with WordApplication1.ActiveDocument.PageSetup do begin
LineNumbering.Active:= PageSetups.LineNumbering.Active;
Orientation:= PageSetups.Orientation;
TopMargin:=PageSetups.TopMargin;
BottomMargin:=PageSetups.BottomMargin;
LeftMargin:=PageSetups.LeftMargin;
RightMargin:=PageSetups.RightMargin;
Gutter:=PageSetups.Gutter;
HeaderDistance:=PageSetups.HeaderDistance;
FooterDistance:=PageSetups.FooterDistance;
PageWidth:=PageSetups.PageWidth;
PageHeight:=PageSetups.PageHeight;
FirstPageTray:=PageSetups.FirstPageTray;
OtherPagesTray:=PageSetups.OtherPagesTray;
SectionStart:=PageSetups.SectionStart; OddAndEvenPagesHeaderFooter:=PageSetups.OddAndEvenPagesHeaderFooter; DifferentFirstPageHeaderFooter:=PageSetups.DifferentFirstPageHeaderFooter;
VerticalAlignment:=PageSetups.VerticalAlignment;
SuppressEndnotes:= PageSetups.SuppressEndnotes;
MirrorMargins:= PageSetups.MirrorMargins;
TwoPagesOnOne:= PageSetups.TwoPagesOnOne;
GutterPos:= PageSetups.GutterPos;
end;
WordApplication1.ActiveDocument.ActiveWindow.Activate;
WordApplication1.Selection.Paste;
FileName:="uved_org_"+IntToStr(i)+".doc";
WordApplication1.ChangeFileOpenDirectory("i:\work\sendmail\1\");
WordApplication1.ActiveDocument.SaveAs
(FileName, FileFormat, LockComments, Password, AddToRecentFiles,
WritePassword, ReadOnlyRecommended, EmbedTrueTypeFonts,
SaveNativePictureFormat, SaveFormsData, SaveAsAOCELetter);
unit_:=wdStory;WordApplication1.Selection.HomeKey(unit_,EmptyParam);
WordApplication1.Selection.Find.ClearFormatting;
with WordApplication1.Selection.Find do begin
Text:= "Ñ.Ì.Áåãàëèåâ";
Replacement.Text:= "";
Forward:= True;
Wrap:= wdFindAsk;
Format:= False;
MatchCase:= False;
MatchWholeWord:= False;
MatchWildcards:= False;
MatchSoundsLike:= False;
MatchAllWordForms:= False;
end;
WordApplication1.Selection.Find.Execute(EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,Emp tyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam);
unit_:=wdCharacter; counts:=3;
WordApplication1.Selection.MoveLeft(unit_, counts, EmptyParam);
FileName:="i:\work\sendmail\1\image001.jpg";
LinkToFile:=False; SaveWithDocument:=True;
WordApplication1.Selection.InlineShapes.AddPicture(FileName, LinkToFile, SaveWithDocument, EmptyParam);
Unit_:=wdStory;
WordApplication1.Selection.EndKey(unit_, EmptyParam);
WordApplication1.Selection.TypeBackspace;
WordApplication1.Selection.TypeBackspace;
WordApplication1.Selection.TypeBackspace;
WordApplication1.ActiveDocument.Save;
WordApplication1.ActiveDocument.ActiveWindow.Close(EmptyParam,EmptyParam);
end;
Except
end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
form1.Close;
end;
end.
Страницы: 1 вся ветка
Форум: "Corba";
Текущий архив: 2005.07.25;
Скачать: [xml.tar.bz2];
Память: 0.48 MB
Время: 0.011 c