someting about OLE

i made a MS Wordart Like Program
how can i make my program can Call form Wiword as an object Like WordArt and insert text's to Word document.
KawsarjanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KawsarjanAuthor Commented:
Adjusted points to 75
0
ptmcompCommented:
You can write it as OLE object or ActiveX then you can insert it in your documents.
0
RBertoraCommented:
Any progress?
Rob ;-)
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

KawsarjanAuthor Commented:
an example would be good :-)
0
RBertoraCommented:
Promted by your question I started fiddeling and got this sample code, which you can play with.. (I think its quite good)

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  comobj, StdCtrls, ExtCtrls,clipbrd;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Image1: TImage;
    Button3: TButton;
    Button4: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  WordApp : Variant;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  try
    WordApp := GetActiveOleObject('Word.Application');
  except on exception do
    WordApp := CreateOleObject('Word.Application');
  end;

  WordApp.Visible := True;
  WordApp.Caption := 'MaindecWord...';
  WordApp.WindowState := 1;

end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  try
    wordApp.quit;
  except on exception do;
  end;

end;


procedure TForm1.Button2Click(Sender: TObject);
var
  Clipboard : TClipboard;
begin

// add a new command bar
  WordApp.Commandbars.Add('Robert',1);
// add a new button
  WordApp.Commandbars['Robert'].controls.Add;
// introduce the hint property
  WordApp.CommandBars['Robert'].Controls[1].DescriptionText := 'MyWordArt';
// Copy a button image to the cliboard
  Clipboard := TClipboard.Create;
  Clipboard.Assign(Image1.Picture.Bitmap);
// paste the image onto the newly created button
  WordApp.CommandBars['Robert'].Controls[1].pasteface;
// show the command bar
  WordApp.CommandBars['Robert'].Visible := True;

// Now go into word and create a word macro that will run your application :
//  Sub Macro1()
//    Shell ("c:/project1.exe")
//  End Sub

// now assign the onaction event to this macro
  WordApp.CommandBars['Robert'].Controls[1].Onaction := 'macro1';
end;

//ok delete the new tool bar
// because you might create many
procedure TForm1.Button3Click(Sender: TObject);
begin
  WordApp.Commandbars['Robert'].Delete;
end;



(*
// ok this procedure is simulating what your wordart application
// have a button with the following lines:

  Clipboard := TClipboard.Create;
  Clipboard.Assign(Image1.Picture.Bitmap);
  WordApp.Activedocument.Content.Paste;
// basically puts image to clipboard and pastes it into your document
// just remember to view your document with onlinelayout or pagelayout
// otherwise you will not see your image pasted in
*)
end.

Rob ;-)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ptmcompCommented:
Hi Rob

I think what you did is the opposite of what Kawsarjan intendet to do, isn't it?
0
KawsarjanAuthor Commented:
it'd good, thanks guys.
0
KawsarjanAuthor Commented:
Hi,
your exmaple was good, i learned a new thing.
but my main target is about how i can insert, delete, replace, analysis and
calculate words in active opem document.
and also how i can call my App by clicking 'Insert Object' menu.
0
ptmcompCommented:
To find your Object in the Insert Object Dialog you have to set a key named 'Insertable' in the registry.

For example a Microsoft Excel Worksheet appears in the insert object dialog cause of this key:
HKEY_CLASSES_ROOT\CLSID\{00020810-0000-0000-C000-000000000046}\Insertable

Regards, ptm.
0
RBertoraCommented:
Hmm sorry.. Glad Kawsarjan learnt something new and anyway I also learnt something new so I'm not dissapointed :-)
Rob ;-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.