php-windows Digest 19 May 2009 21:58:17 -0000 Issue 3626

Topics (messages 29341 through 29342):

Re: Excel OLE Automation using COM: file access problem
        29341 by: Richard Quadling

You need to lose fat?
        29342 by: Richie Carbaugh

Administrivia:

To subscribe to the digest, e-mail:
        php-windows-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-windows-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-wind...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
2009/5/19 Faubry, Samuel <samuel.fau...@parexel.com>:
>> From: Richard Quadling
>> 2009/5/18 Faubry, Samuel <samuel.fau...@parexel.com>:
>> > Hi,
>> >
>> > I am interfacing PHP and Excel to build a web-based
>> reporting tool. I am running IIS6.0 with PHP 5.2.5 on Windows
>> Server 2003, with Office 2003 installed.
>> >
>> > For testing purpose, I wrote a script that just connects to
>> Excel, opens a workbook, saves it under another name and closes Excel:
>> >
>> > $if_path = 'C:\if_test.xls';
>> > $of_path = 'C:\of_test.xls';
>> >
>> > echo date('H:i:s') . " Launch Excel application \n";
>> > $excelApp = new COM("Excel.Application") or die("Cannot
>> create an Excel object");
>> > echo date('H:i:s') . " Loaded Excel, version
>> {$excelApp->Version}\n";
>> >
>> > echo date('H:i:s') . " Open workbook at path $if_path\n";
>> > $excelApp->Workbooks->Open($if_path, 2);
>> >
>> > echo date('H:i:s') . " Save changes to $of_path\n";
>> > $excelApp->Workbooks[1]->SaveAs($of_path);
>> >
>> > echo date('H:i:s') . " Close Excel\n";
>> > $excelApp->Quit();
>> >
>> > When I open the page in Internet Explorer, if I put
>> "http://localhost/test.php";, everything works fine, but if I
>> put "http://my_server_name.domain.int/test.php";, the script
>> is blocked when trying to open the file, which means I can't
>> access the script elsewhere than on the server.
>> >
>> > By "blocked", I mean no error is shown, but it doesn't
>> react, and the excel.exe task keeps running and keeps the file locked.
>> >
>> > My guess is that Excel is run with different permissions in
>> the second case, so it cannot access the file, but it might
>> be completely something else...
>> >
>> > Does someone have any experience in that matter ?
>> >
>> > Thank you very much !
>> >
>> >
>>
>> If it is permissions, TEMPORARILY, allow IIS to interact with the
>> desktop. Hopefully you can RDP to the server as the console and see
>> what error message pops up (if any).
>>
>> As PHP and excel run on the server, you will need to see the server
>> for any errors that can be displayed in this regard.
>>
>> I don't think you'll be able to do this on server 2008 as the
>> "console" is no longer displayed (session 0 is purely for internal use
>> only - services and the like - and no display is allowed).
>>
>>
>> --
>> -----
>> Richard Quadling
>> Zend Certified Engineer :
>> http://zend.com/zce.php?c=ZEND002498&r=213474731
>> "Standing on the shoulders of some very clever giants!"
>>
>
> Hi, thanks for your reply, Richard.
>
> I RDP'd to the server console, but no error pops up. I allowed IIS to
> interact with the desktop, but I didn't change anything.
>
> I might have found the problem: the file I am trying to open has
> external links. With a "normal" file it works fine whatever way I run
> the script.
>
> That's why I used the second argument (UpdateLinks) in the Open call
> documented here (2 means "Never update links for this workbook on
> opening"):
> http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.w
> orkbooks.open(office.11).aspx
>
> Apparently, the argument I passed (2 of PHP type integer) is invalid.
> Let me explain why I think so:
> In the following, I am running everything from
> http://localhost/test.php, which allows user interaction.
> If I put $excelApp->Visible = 0 and use 2 as the UpdateLinks argument to
> Open, everything runs fine without any interaction with the user.
> If I put $excelApp->Visible = 1 and use 2 as the UpdateLinks argument to
> Open, Excel shows up and tells me the links could not be updated, which
> means it tried to update it, which is NOT the expected behaviour!
> The values 1, 2 and 3 all give the same result, which is contradictory
> with the documentation (1 is "ask", 2 is "do not update" and 3 is "do
> update").
> If I put 0, Excel shows up and closes without any interaction, but 0 is
> not an authorised value according to the documentation.
> Any other value crashes the script.
> If I don't specify this argument, Excel shows up and asks me if I want
> to update, which is the expected behaviour.
>
> According to the documentation, this UpdateLinks argument is an Object,
> maybe that's where the problem lies? If so, how can I create the object
> to be passed as an argument to Open?
>
> By the way, just out of curiosity, I tried to use the value 0 and run
> the script from a client computer, but it is still blocked in the way
> described above.
>
> Thanks for your help !
>

A couple of things (taken as snippets from the online help and looking
through the type library) ...

AskToUpdateLinks Property
See AlsoApplies ToExampleSpecificsTrue if Microsoft Excel asks the
user to update links when opening files with links. False if links are
automatically updated with no dialog box. Read/write Boolean.

Example
This example sets Microsoft Excel to ask the user to update links
whenever a file that contains links is opened.

Application.AskToUpdateLinks = True
                


Do you have any macros as part of the file you open? If they present
dialogs, maybe they need to be suppressed also?

Application.DisplayAlerts = False
Workbooks("BOOK1.XLS").Close
Application.DisplayAlerts = True



Application.Workbooks.Open

UpdateLinks   Optional Variant. Specifies the way links in the file
are updated. If this argument is omitted, the user is prompted to
specify how links will be updated. Otherwise, this argument is one of
the values listed in the following table.

Value Meaning
0 Doesn't update any references
1 Updates external references but not remote references
2 Updates remote references but not external references
3 Updates both remote and external references


Hmm..

Is it possible for you to run the PHP script from the command line on
the server using the same credentials used by IIS (or the app pool
used). I'm still not 100% uptodate with IIS+PHP security using
FastCGI. If you can get the script running, make sure you turn on
visibility within/for Excel so you can see what is happening.

-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

--- End Message ---
--- Begin Message ---
Hello!

You don't like what You see in the mirror and You need a change RIGHT NOW? Or 
You tried everything and still no visible result? Or You just want to be 
healthy? Then, AcaiBurn Detox is for You!
Studies have shown that the Amazon fruit Acai is one of the most nutritious and 
powerful foods in the world. Hidden within its royal purple pigment is the 
magic that makes it nature's perfect energy fruit. A synergy of monounsaturated 
(healthy) fats, dietary fiber and phytosterols to help promote cardiovascular 
and digestive health.
Finally the magic fruit is reaching to the people! Still not convinced? Then 
the FREE Trial is for You!
All you have to do is to confirm your interest at 12126ella.edger...@gmail.com 
and we'll send You the necessary information.

Best regards,
Acai Marketing Inc.











------------------------------------------------------------------
This email has been written and proved to be in compliance with the recently 
established can-spam act law in US. We are not provoking or forcing any person 
in any way to participate in our programs. To participate is your own decision 
and you carry the responsibility of taking further part in this promotion. 
Anyway, if you don't want to receive more good offers from us, you can simply 
Unsubscribe by sending us a notification email to get.out_from_l...@yahoo.com 
with a mail-subject and text "Unsubscribe me", and we will get your email out 
of our list within 10 days.

This message is STRICTLY CONFIDENTIAL and is solely for the individual or 
organisation to whom it is addressed. It may contain PRIVILEGED and 
CONFIDENTIAL information. If you are not the intended recipient, you are hereby 
notified that any dissemination, distribution or copying of this communication 
and its contents is strictly prohibited. If you are not the intended recipient 
you should not read, copy, distribute, disclose or otherwise use the 
information in this email. Email may be susceptible to data corruption, 
interception and unauthorised amendment, and we do not accept liability for any 
such corruption, interception or amendment or the consequences thereof or your 
reliance on any information contained therein if you are not the intended 
recipient. If you are not interested in the offered promotions, please just 
don't answer. If you think you have received this message and its contents in 
error, please delete it from your computer, or follow the unsubscribing 
procedure shown above.
------------------------------------------------------------------
                

--- End Message ---

Reply via email to