Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

GetActiveOleObject question

Posted on 2004-09-29
6
Medium Priority
?
1,316 Views
Last Modified: 2008-01-09
Hi,
I am trying to use an Activex object in my application.
The VB sample coming with the object works properly opening an Application and a Document; the sample sounds like this:

Dim App, Data, pathToDoc
    Set App = GetObject(, "XXXXX.Application")
    pathToDoc = App.GetActiveDocPath

    If pathToDoc="" Then 'if no data file exists
........................
    End If
 
    Set Data = GetObject(pathToDoc) '..where pathToDoc is the full name of the Document referenced by the object

And I get full controll over the Data object

I don't know how to code in Delphi
Set Data = GetObject(pathToDoc)

Can anyone help me?
Thanks
0
Comment
Question by:dciambrone
[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
6 Comments
 
LVL 2

Accepted Solution

by:
php4delphi earned 1000 total points
ID: 12183661
Delphi has no exact equivalent for GetObject function. If you want execute Application (there is no active application running) you have to use CreateOleObject function, otherwise GetActiveOleObject function.
For example,

procedure StartOrLinkToWord;
var
 V: Variant;
begin
 try
  V := GetActiveOleObject('Word.Application');
 except
  V := CreateOleObject(Word'.Application');
 end;

 // Do something with V here...
end;
0
 

Author Comment

by:dciambrone
ID: 12188432
My question is:
With the previous Activex version I used the Delphi method CreateOleObject and everithing was OK.
The new release of the activex has some problems and I am trying to work around the problem waiting for this problems to be fixed.
The above VB code works fine; is there a way to let Delphi work anyway?
Thanks in advance
0
 
LVL 6

Assisted Solution

by:david_barker
david_barker earned 1000 total points
ID: 12189481
You can't exactly do the same with Delphi.
What VB does with GetObject when you just supply a filename is to determine the application to start and the object to activate, based on the file name you provide.
In Delphi, you will have to know the classname of this application, ie. "Word.Application" if the file is a Word document.

procedure Test;
var
  App       : Variant;
  pathToDoc : Variant;
  Data      : Variant;
begin
  App:=CreateOleObject('XXXXX.Application');
  pathToDoc:=App.GetActiveDocPath;
  if pathToDoc='' then // if no data file exists
  begin
    // .....
  end;
  //
  Data:=CreateOleObject('YYYYY.Application');
  Data.Open(pathToDoc);   // Open might be the correct method in your case
end;
0

Featured Post

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.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Suggested Courses

598 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