Board index » delphi » VB-makro calling from Dephi

VB-makro calling from Dephi

Hi,

I wrote a simple program, which send dates (by late binding methode *))
to an excel-sheet. Now I improved the appearace of the sheet 'by hand'
during recording the VB-steps. I copied these steps to a file (txt) and
want now:
Start the delhi-program, make the sheet, improve the appearance by
calling the VB-makro.

I tried :
XLApp := CreateOleObject('Excel.Application');
...
...
// make all for the simpelst sheet
...
...
Xlapp.RUN('C:\pf1\pf2\...\makro1.txt!sub1'); // dirctory + makro-name

The massage was, Excel couldn't find the makro

What's wrong?

I would be glad, if someone can send me some code for it or give me some
helps

Many thanks
Frank-R.

*) I'm just trying to learn the early-binding-methode reading Deborah's
really great homepage.

 

Re:VB-makro calling from Dephi


<<Frank-Reinhard Ulrich:
I copied these steps to a file (txt) and want now:
Start the delhi-program, make the sheet, improve the appearance by
calling the VB-makro.

Quote

Can a macro be run from a text file in Excel? I've never
heard of this being done, anyway.

This will work, if you have a workbook called book1 in the
appropriate directory:
  Xlapp.RUN('Book1.xls!sub1');

--
Deborah Pate

Re:VB-makro calling from Dephi


Deborah Pate schrieb:
Quote

> Can a macro be run from a text file in Excel? I've never
> heard of this being done, anyway.

> This will work, if you have a workbook called book1 in the
> appropriate directory:
>   Xlapp.RUN('Book1.xls!sub1');

> --
> Deborah Pate

Hi Deborah,
many thanks for your answer.- My problem is, the makro should be on its
own file, written e.g. some days before.
Now the the delphi-program writes its dates to an excel-sheet
(XlApp.visible:=true) and starts the (old-) makro to improve the (still)
simple output. ( After this the user could decide, to print out or to
make more improvements.)
Therefore the extension txt, I assumed, the extension is only for
'automatic start', starting by RUN it doesn't make any difference. It's
wrong, i see.
However, I do not know whether my plan is at all possible; and this is
my main problem.

--
Frank-R.

Re:VB-makro calling from Dephi


<<Frank-Reinhard Ullrich:
My problem is, the makro should be on its
own file, written e.g. some days before.

Quote

Yes, but why can't that file be an Excel Workbook?

--
Deborah Pate

Re:VB-makro calling from Dephi


Deborah Pate schrieb:

Quote

> <<Frank-Reinhard Ullrich:

> Yes, but why can't that file be an Excel Workbook?

> --
> Deborah Pate

Hi Deborah,
yes, you are quite right. I tested it yesterday evening and  the program
said every time it can't find the makro. I think, either I make a
fundamental error or it isn't possible to start a 'foreign makro' in an
open, activated(?) excel workbook :-(( .
--
Frank-R.

Re:VB-makro calling from Dephi


<<Frank-Reinhard Ullrich:
I think, either I make a fundamental error or it isn't possible to
start a 'foreign makro' in an open, activated(?) excel workbook :-(( .

Quote

You made a fundamental error. :)

I'm not sure what, though - unless you're trying
to specify a path. You can't do 'C:\Book1.xls!Macro1',
you have to do 'Book1.xls!Macro1' and make sure
Book1 is in the right directory.

--
Deborah Pate

Other Threads