First I would like to reply to this with an update on how I got it to work.  Learned 
some very interesting things.  Second, I have another question.

1)---------
I did not end up using a macro, but instead translated the statements to the following 
based on your help Neil:

(example)
$this->xlEdgeBottom = 9;
$this->xlContinuous = 1;

$range = $sheet->Range("A5:E5");
com_propput($range->Borders($this->xlEdgeBottom),LineStyle,$this->xlContinuous);

Notice that I defined the variables for xlEdgeBottom and xlContinuous.  The reason is 
that these are constants in excel and if you use the constant names, everything freaks 
out.  I actually had to lookup the constants by name and get their values in excel.  
Running the values through the PHP COM functions did the trick.  If there is a shorter 
way to do this, please let me know.

The other thing is that the "Borders" property in excel does not appear to return an 
object.  Therefore, given the syntax limitations, I could not do the following:

$range->Borders($this->xlEdgeBottom)->LineStyle = $this->xlContinous;
or
$border = $range->Borders($this->xlEdgeBottom);
$border->LineStyle = $this->xlContinous;

I therefore had to use the com_propput function as stated above.

2)---------
Now, I have the following syntax in VB that I need to convert to PHP:

Range("A7:E20").Select
Selection.Sort Key1:=Range("A7"), Order1:=xlAscending, Header:=xlGuess, 
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

It looks you can specify multiple key paramaters as you can sort by more than one 
column.  I think you might be able to see my difficulty here... some of that syntax is 
pretty weird.

-Ethan Nelson,
Modulus, LLC


-----Original Message-----
Why not try to execute the macro,

$Excel->application->run("book.xls!macro");

but if this is not possible / desirable, the with statement: 

   With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
   End With

is only a shorthand way of specifying

   Selection.Borders(xlEdgeBottom).LineStyle = xlContinuous
   Selection.Borders(xlEdgeBottom).Weight = xlThin
   Selection.Borders(xlEdgeBottom).ColorIndex = xlAutomatic

Hope this helps,
Regards,
Neil Morgan

-----Original Message-----
From: Ethan Nelson [mailto:[EMAIL PROTECTED]
Sent: 28 October 2003 22:13
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] Help with COM


Hello,

I am trying to write some excel functions in PHP 4.3.3 using the COM
interface.  The objective it to create a "BottomEdge" border with regular
line styles etc...  The actual visual basic code that the macro recorder in
excel writes goes as follows:

Range("A13:E13").Select
   Selection.Borders(xlDiagonalDown).LineStyle = xlNone
   With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With

Now my code is in object and looks something like:

$this->sheet->column->EntireColumn->Font->Bold=true;

That would be an example of how I would make an entire column bold (I
think).  Anyway... how the heck do I do a "with" statement using this PHP
syntax?  I tried separating each line into objects but tells me it can't
find function "Border":

$range = $this->sheet->Range("A13:E13");
$selection = $range->Select;
$diagdown = $selection->Borders(xlDiagonalDown);
$diagdown->LineStyle = xlNone;

...

with?

Thanks for the help... I'm pretty new at trying to translate VB syntax into
a compatible PHP code.

-Ethan Nelson,

Modulus, LLC

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to