Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

OLE novice needs help

Posted on 1999-06-29
10
Medium Priority
?
187 Views
Last Modified: 2010-04-06
I need to open an(y) Ole document by its filename. I tried to use TOleContainer to open it in its server, but TOLEContainer seems to need a parent window. I do not want to show the TOLEContainer, and also, the code for opening this file should not be placed at the GUI level, so I cannot, for this and several other reasons, provide a parent window. I need both opening of a new OLE document by the standard dialog, as well as opening from existing files.
Can I do this with TOLEContainer without providing owner & parent? -Or is there another smart way?
0
Comment
Question by:classmate
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 2

Author Comment

by:classmate
ID: 1385197
Regards, classmate
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1385198
I once tried to do something with Word. I am not sure if this works without a form:


procedure TForm1.Button1Click(Sender: TObject);
var
  Word: OleVariant;
begin
  Word := CreateOleObject('Word.Application');
  Word.WordBasic.FileNew('Normal');
  Word.WordBasic.Insert('This is the first line'#13);
  Word.WordBasic.Insert('This is the second line'#13);
  Word.ActiveDocument.PageSetup.LeftMargin := 12;
  Word.Run('Macro1');
  Word.WordBasic.FileSaveAs('test.doc');
  Word.WordBasic.FileClose;
end;

0
 
LVL 2

Author Comment

by:classmate
ID: 1385199
Thanks, I'll try it tomorrow at work.
But i need to open the dialog that selects the kind of OLE object to create (case A), and i also need to create the OLE object by an existing ole document file (case B). In both cases i want to start the server application, forcing the user to edit his/her document within this. In my own program i store the filename. The API call i need is probably the same as the one used when a user double clicks on a non-exe file in Explorer.

class mate.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 13

Expert Comment

by:Epsylon
ID: 1385200
Well, this looks like you are looking for ShellExecute API...
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1385201
Uses ShellApi;

.........

procedure TForm1.Button3Click(Sender: TObject);
begin
  ShellExecute(0, 'open', 'notepad', 'autoexec.bat', 'c:\', SW_SHOW);
end;

0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1385202
or

  ShellExecute(0, 'open', 'windows', '', 'c:\', SW_SHOW);

0
 
LVL 2

Author Comment

by:classmate
ID: 1385203
Thanks
I'll keep you updated on my results

class mate
0
 
LVL 2

Author Comment

by:classmate
ID: 1385204
I tested in this way:

procedure TForm1.Button1Click(Sender: TObject);
begin
   Opendialog1.execute;
   ShellExecute (0,
                 'open',
                 '',
                 PChar (OpenDialog1.Filename),
                 PChar (ExtractFilePath (Opendialog1.filename)),
                 SW_SHOW);
end;


The only problem is that I need to determine the program to be started; as you can see I have a blank string at that parameter. My example makes an Explorer window start. I need a kind of "GetRegisteredFileTypeApp" function...
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 600 total points
ID: 1385205
Just a little change:

procedure TForm1.Button1Click(Sender: TObject);
begin
   Opendialog1.execute;
   ShellExecute (0,
                 'open',
                 PChar (OpenDialog1.Filename),
                 '',
                 PChar (ExtractFilePath (Opendialog1.filename)),
                 SW_SHOW);
end;


That should do it   :o)

Epsylon.
0
 
LVL 2

Author Comment

by:classmate
ID: 1385206
My brain was left in bed today ;) I actually thought of trying that yesterday. Anyway the points are yours, you've earned them!

Regards,
class mate.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

704 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