[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

someting about OLE

Posted on 1999-11-12
10
Medium Priority
?
176 Views
Last Modified: 2010-04-04
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.
0
Comment
Question by:Kawsarjan
  • 4
  • 3
  • 3
10 Comments
 

Author Comment

by:Kawsarjan
ID: 2203309
Adjusted points to 75
0
 
LVL 10

Expert Comment

by:ptmcomp
ID: 2206334
You can write it as OLE object or ActiveX then you can insert it in your documents.
0
 
LVL 7

Expert Comment

by:RBertora
ID: 2207793
Any progress?
Rob ;-)
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 

Author Comment

by:Kawsarjan
ID: 2209476
an example would be good :-)
0
 
LVL 7

Accepted Solution

by:
RBertora earned 210 total points
ID: 2217535
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
 
LVL 10

Expert Comment

by:ptmcomp
ID: 2217889
Hi Rob

I think what you did is the opposite of what Kawsarjan intendet to do, isn't it?
0
 

Author Comment

by:Kawsarjan
ID: 2221809
it'd good, thanks guys.
0
 

Author Comment

by:Kawsarjan
ID: 2223346
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
 
LVL 10

Expert Comment

by:ptmcomp
ID: 2223396
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
 
LVL 7

Expert Comment

by:RBertora
ID: 2224592
Hmm sorry.. Glad Kawsarjan learnt something new and anyway I also learnt something new so I'm not dissapointed :-)
Rob ;-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…
Suggested Courses

608 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question