Arsip: Export to Ms.Word

 
user image
more 13 years ago

bboyz

Hi, master-master semua, saya baru gabung disini nih...Saya da kesulitan dengan mengeksport teks ke Ms.Word...Thanx Be4 :lol:
user image
more 13 years ago

walking_body

coba aja kmu pake oleobject
user image
more 13 years ago

bagussb

ini saya punya class nya... tapi dulu ga tau dapet dari mana... lupa lagie... :)
unit unWinWord;
interface
uses
  Word2000, Windows, SysUtils, Variants;
type
  TWinWord = class
  private
    App : _Application;
    function fGetVisible : boolean;
    procedure fSetVisible(visible : boolean);
  public
    procedure NewDoc(Template : String);
    procedure GotoBookmark(Bookmark : String);
    procedure InsertText(Text : String);
    procedure MoveRight(Count : integer);
    procedure Print;
    procedure UpdateFields;
    procedure SaveAs(Filename : string);
    Procedure RunMacro(MacroName : string);
    constructor Create;
    destructor Destroy; override;
    property visible : boolean read fGetVisible write fSetVisible;
  end;
implementation
constructor TWinWord.Create;
begin
  App := CoWordApplication.Create;
end;
destructor TWinWord.Destroy;
var
  SaveChanges : OLEVariant;
  OriginalFormat : OLEVariant;
  RouteDocument : OLEVariant;
begin
  SaveChanges := wdDoNotSaveChanges;
  OriginalFormat := unAssigned;
  RouteDocument := unAssigned;
  app.Quit(SaveChanges, OriginalFormat, RouteDocument);
  inherited destroy;
end;
function TWinWord.fGetVisible : boolean;
begin
  result := App.Visible;
end;
procedure TWinWord.fSetVisible(Visible : boolean);
begin
  App.visible := Visible;
end;
procedure TWinWord.GotoBookmark(Bookmark : string);
var
  What : OLEVariant;
  Which : OLEVariant;
  Count : OLEVariant;
  Name : OLEVariant;
begin
  What := wdGoToBookmark;
  Which := unAssigned;
  Count := unAssigned;
  Name := Bookmark;
  App.Selection.GoTo_(What, Which, Count, Name);
end;
procedure TWinWord.InsertText(Text : String);
begin
  App.Selection.TypeText(Text);
end;
procedure TWinWord.NewDoc(Template : String);
var
  DocTemplate : OleVariant;
  NewTemplate : OleVariant;
begin
  DocTemplate := Template;
  NewTemplate := False;
  App.Documents.AddOld(DocTemplate, NewTemplate);
end;
procedure TWinWord.MoveRight(Count : integer);
var
  MoveUnit : OleVariant;
  vCount : OleVariant;
  Extended : OleVariant;
begin
  MoveUnit := wdCell;
  vCount := Count;
  Extended := unassigned;
  app.selection.MoveRight(MoveUnit, vCount, Extended);
end;
procedure TWinWord.Print;
begin
  OLEVariant(app).Printout;
end;
procedure TWinWord.UpdateFields;
begin
  App.ActiveDocument.Fields.Update;
end;
procedure TWinWord.SaveAs(Filename : string);
begin
  OLEVariant(App).ActiveDocument.SaveAs(FileName);
end;
procedure TWinWord.RunMacro(MacroName : string);
begin
  App.RunOld(MacroName);
end;
end.
user image
more 13 years ago

bboyz

Saya pake komponen "WordApplication1" en "WordDocument1", truz saya pake procedure "WordDocument1.Range.Select" utk mem-blok kalimat-kalimatnya utk diatur font size en font bold-nya, tp smua kalimat ikut ke-blok jadi semua kalimatnya mengikuti pengaturan font size en font bold yang paling akhir..tolong dibantu ya...thanx
user image
more 13 years ago

bboyz

oh iya mas, "procedure TWinWord.MoveRight(Count : integer);" tuh utk format tabel ya ?
user image
more 13 years ago

bagussb

yups... itu semacam menekan tombol TAB...
user image
more 13 years ago

bboyz

sory mas di bawah ini potongan coding yg saya pake, tapi msh acak2an coz masih dicoba2..Klo ga keberatan tolong dicek, saya belum bisa memisahkan kalimat-kalimat yang di-blok... WA.Visible:=true; WA.Caption:='Ngetest'; WD.Range.Select; WD.Range.Text:='Ngetest'; WD.Range.Font.Size:=18; WD.Range.Font.Bold:=1; WD.Range.Select; WD.Range.InsertAfter(#13+'Ini aplikasi utk uji coba'); WD.Range.Font.Size:=10; WD.Range.Font.Bold:=0; WD.Disconnect; WA.Disconnect; Ket : WA => WordApplication1 WD => WordDocument1
user image
more 13 years ago

bagussb

kalo ngga salah untuk range, ada overloadnya. dicoba begini bisa ngga yah : a := 1; b := 10; with WD.Range(a,b).Font do begin Bold := 1; Size := 18; end; dimana a dan b itu OleVariant, trus nilainya nunjukin posisi karakternya...
user image
more 13 years ago

bboyz

Mas, Sory neh kayaknya dah basi tapi thanx bgt dah bantu mecahin problem saya...skali lagi hatur nuhun...
user image
more 13 years ago

BoedaxBanten

Saya mau Nyetak Laporan Ke Ms.Word XP atau Word 2000, gimana caranya,makasih
more ...
  • Pages:
  • 1
Share to

Random Topic

Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com