Solved

EXCEL & DELPHI

Posted on 1997-03-11
8
1,295 Views
Last Modified: 2010-08-05
I have an application written in Delphi.
From this Delphi program, I need to execute Excel (previously configured), to fill some cells in a choosen sheet, launch a macro linked to the choosen sheet, and re-read the computed values from some choosen cells.
Maybe I've to use TOleObject or OLE method itself, but I don't know how to and need a focused related example.

Regards

poli_amf@computech.it
0
Comment
Question by:straker
[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
8 Comments
 

Expert Comment

by:pscadden
ID: 1334872
For starters get the TExcel component from the Delphi
super page. (http://dsp.static.co.kr/index.html is the mirror that I use) It talks to Excel via DDE. It isnt perfect, but its a good
start.
0
 

Author Comment

by:straker
ID: 1334873
I started talking about OLE and ToleObject such in word.basic example.
That is ... I need an example that shows me how to use the feature of the ole to open a choose .xls to find a choosen sheet, to launch a macro and to read and to get values back and forth a range of cells...but via OLE such all the examples that everybody could find in litterature and concerning ... createOleObject('word.basic')  ........ ('Excel.Application').

Regards
0
 
LVL 3

Expert Comment

by:mheacock
ID: 1334874
I don't thin this is a 50 pt question.  You are looking for
quite a lot of advanced OLE here.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:straker
ID: 1334875
I believe it's not so advanced.
The Word example is very simple. (If I try to register the Macro in Word a can move it quite step by step in the Delphi program and it can be found in every serious Delphi Book) [ Teixeira docet].
In Excel this translation seems not to work. I asked only the four instructions to pilot the reach of a choosen WorkBook, a choosen WorkSheet, to exec a Macro in the WorkSheet and to read and write some Cells. It seems to me not an HARD OLE question.
I Can Add 50 points but it seems a waste of resource.

Regards
0
 
LVL 3

Expert Comment

by:sperling
ID: 1334876
English is my second language, and I 'm not sure I understand you...


You need e.g. a short procedure, which tells you what OLE objects you should create, and what methods you should call, to

1) Open a given XLS
2) Execute a predefined macro
3) Write to cells
4) Read from cells.

You know how to create the objects, you just need object names and methods.

Right??

Erik.
0
 

Author Comment

by:straker
ID: 1334877
'cause English is not my second language I'll try to explane my problem in short...
I've just executed the Excel.exe and performed  the createOleObject('Excel.Application'). Now I'd like obtain  ( via OLE ) the following operation:
1- Given a workbook name, to open it.
2- Given a worksheet name, to select it.
3- Given a Row and a Column, to write to it.
4- Given a macro name in the current worksheet, to execute it.
5- Given a Row and a Column, to read from it.

That's all.

Regards.



0
 
LVL 3

Expert Comment

by:sperling
ID: 1334878
This is a 50p question... Just a matter of looking up the right Excel functions... I've got some code doing approximately this, I'll try to locate it and then give an answer...

Erik.
0
 
LVL 3

Accepted Solution

by:
sperling earned 50 total points
ID: 1334879
Excel := CreateOLEObject('Excel.Application');

Excel.Workbooks.Open('C:\WS1.XLS');
Excel.ActiveWorkbook.Worksheets('WorkSheet1').Activate;
s := Excel.ActiveWorksheet.Cells(ARow, ACol);
Excel.ActiveWorksheet.Cells(ARow, ACol) := s;
Excel.Run('MACRO.XLM!MacroName', 1, 2);

As I ain't got the US version of Excel, the actual method names might not be accurate. According to the docs (which ofcourse documents the US version, not the localized version, sigh...) this ought to work. If not, leave me a comment, and I'll check it out.

Erik.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Title # Comments Views Activity
Delphi selector screen 2 97
Convert a string into a TDateTime 5 81
shape, triangle, dbctrlgrid 3 47
migrate this code to work on android 1 46
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

752 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