Jump to content

problems with COM-Excel


Bobboau

Recommended Posts

ok, so I need to generate some reports from a few excel spread sheets on my network. it seems like this would be simple enough, just make the Excel COM object read the data and go. unfortunately it just doesn't seem to work when ever I try to open a file I get a "can't open it for some reason" error (specificly: "Microsoft Office Excel cannot access the file 'filenamehere.xls'. There are several possible reasons: • The file name or path does not exist. • The file is being used by another program. • The workbook you are trying to save has the same name as a currently open workbook.'"). I can open the file if I paste the path into the address bar manually just fine. this has happened with every excel file I have tried to open, no matter where they are. I think it's some sort of permissions thing, but I don't get how that could be or how to fix it.

 

I am running through Apache on a Vista machine.

Link to comment
Share on other sites

ok, so I need to generate some reports from a few excel spread sheets on my network. it seems like this would be simple enough, just make the Excel COM object read the data and go. unfortunately it just doesn't seem to work when ever I try to open a file I get a "can't open it for some reason" error (specificly: "Microsoft Office Excel cannot access the file 'filenamehere.xls'. There are several possible reasons: • The file name or path does not exist. • The file is being used by another program. • The workbook you are trying to save has the same name as a currently open workbook.'"). I can open the file if I paste the path into the address bar manually just fine. this has happened with every excel file I have tried to open, no matter where they are. I think it's some sort of permissions thing, but I don't get how that could be or how to fix it.

 

I am running through Apache on a Vista machine.

 

firewall accesslist ?

Link to comment
Share on other sites

right now I am doing everything on the same machine, so mySQL, Apache, the excel files, me using firefox accessing my own ip address, it's all on the same computer. I will of course want to access remote files and access everything from other computers eventualy, but for the moment I'm just trying to do local development.

 

just tried putting it in the public folder, no change.

 

I just turned the firewall completely off and tried it, no go.

 

 

 

if it helps this is what I currently have in the php file

 

$PPMH_path = "C:\\Users\\Public\\test.xls";

try{
$excel=new COM("excel.application") or die("unable to start Excel on server!");

$excel->DisplayAlerts = 0; 
$excel->Visible = 0;
$excel->Workbooks->Open($PPMH_path);
$excel->Quit();

} catch (Exception $e) {
echo "\n**error** ".$e;
$excel->Quit();
}

Link to comment
Share on other sites

what you mean COM? I'm fairly sure it's a standard extension for windows.

http://us.php.net/manual/en/book.com.php

 

I specifically need to use the COM interface because I have to deal with a bunch of different excel versions. the error happens only if I try to read or write a file with it, if I just perform tasks on a new excel sheet it works fine as far as I can see, but that is fairly useless.

Link to comment
Share on other sites

what you mean COM? I'm fairly sure it's a standard extension for windows.

http://us.php.net/manual/en/book.com.php

 

I specifically need to use the COM interface because I have to deal with a bunch of different excel versions. the error happens only if I try to read or write a file with it, if I just perform tasks on a new excel sheet it works fine as far as I can see, but that is fairly useless.

iv never connected using com in php and didnt spot it in the code sorry. i thoght u were using some 3rd party stuff with com in it.

Link to comment
Share on other sites

just turned UAC off and tried again, does not effect anything.

 

(other than vista is now nagging me of the impending doom caused by turning it off.:) )

 

also I have gone into the service controls and told the Apache server to log in with my credentials

Link to comment
Share on other sites

/*hit quote when I meant to hit edit*/

 

right click the directory u need to access and go to its premissions and add the server etc i forgot what teh services account is, the prob is taht is for IIS so there must be another account for APACHE u probs need to see who it runs under and give appropriate permisssions on that directory.

Link to comment
Share on other sites

well it runs under my account, and I have all the permissions in the world. not to mention it's the public folder I'm trying to access right now, that has just about the loosest security of anything in vista.

 

but I just tried reading from a folder that I granted full control to just about everything I could see that could conceivably include Apache.

Link to comment
Share on other sites

what sort of software/driver do you think I might be missing? excel works fine on it's own.

 

is it possible this is a bug in PHP? I get the impression not many people use this extension, and it might just not work under vista. I am somewhat hesitant to imply it's not my fault this is working, but it seems like no one knows anything about this interface.

or maybe I'm just looking in the wrong places.

Link to comment
Share on other sites

You are responsible for installing support for the various COM objects that you intend to use (such as MS Word); we don't and can't bundle all of those with PHP.

 

 

Have you done the above? Thats from the Documentation...

 

tru that and also php on vista i had soem issues so there must still be some, but the extensions above u need to install them like the docs for php say.

Link to comment
Share on other sites

You are responsible for installing support for the various COM objects that you intend to use (such as MS Word); we don't and can't bundle all of those with PHP.

 

 

Have you done the above? Thats from the Documentation...

 

the com objects are installed with office, I know they work because if I use javascripting they work fine, and other than file related activities they seem to work fine in PHP, it is specificly I can not open or save a file.

 

unless there is something specific for PHP I am not aware of.

Link to comment
Share on other sites

You are responsible for installing support for the various COM objects that you intend to use (such as MS Word); we don't and can't bundle all of those with PHP.

 

 

Have you done the above? Thats from the Documentation...

 

the com objects are installed with office, I know they work because if I use javascripting they work fine, and other than file related activities they seem to work fine in PHP, it is specificly I can not open or save a file.

 

unless there is something specific for PHP I am not aware of.

 

you go into php.ini and un-cooment the extentsion in the extensions section because it is not un-commented by default so it is not loaded.

Link to comment
Share on other sites

I uncommented everything related to COM in the ini file, I still have the same problem.

 

I doubt this is the issue because I do get the excel COM object and it works exept for anything to do with files. the error I get is from the COM object it's self so PHP is makeing a working COM object.

Link to comment
Share on other sites

I uncommented everything related to COM in the ini file, I still have the same problem.

 

I doubt this is the issue because I do get the excel COM object and it works exept for anything to do with files. the error I get is from the COM object it's self so PHP is makeing a working COM object.

 

go to the php website look up the object check the versions required etc vista compatability etc, or do google searches for teh compatability of it with vista or your php version with vista etc

Link to comment
Share on other sites

  • 4 months later...

I have figured out what is wrong, but I still am not able to fix it.

Apparently office 2007 if run as a service in vista will not be allowed access to the file system. so, because Apache is running as a service, PHP is therfore running as a service and Excel is running as a service. I've tried a number of ways to try and get around this, but nothing seems to do it.

 

I have tried running stuff as elaborate as running a javascript file from a system command line using psexec called by system(). none of this has been able to get around the service issue. so unless someone knows a way to spawn a command process in a different session and not as a service there will be no solution to this.

 

it is 'almost' as if they have specifically made it impossible to use office on a server. oh, interestingly they have a new office version specifically for doing just that sort of thing. completely coincidental that.

 

I hate microsoft.

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.