SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast gazman99's Avatar
    Join Date
    May 2007
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Windows 2008 PHP new COM(powerpoint.application)

    Im using the following code below to open and export ppt slides as jpegs and this works fine on a windows 2003 server but on a windows 2008 server I get the following error:
    "Caught exception: Source: Microsoft Office PowerPoint 2007 Description: PowerPoint could not open the file.D:\wwwroot\SlideManagerDemo\public\temp\test.ppt"
    On windows 2008 I can see from the task manager that when I run this page, it creates the application instance fine but when I try to open/create files it just falls over.

    (I do have msoffice 2007 installed on server)

    Anyone have any further ideas (im sure im missing a tickbox somewhere?)

    PHP Code:
    $strPath realpath(basename(getenv($_SERVER["SCRIPT_NAME"])))."\\temp\\";
    $ppApp = new COM("powerpoint.application") or die("Unable to instantiate Powerpoint");
    $ppApp->Visible True;

    $ppName $strPath."test.ppt";
    $FileName "slides";

    //*** Open Document if exists***//
    if(file_exists($ppName)) {
        try {
            
    $pres $ppApp->Presentations->Open($ppNameFalseTrueTrue);
        } catch (
    Exception $e) {
            echo 
    'Caught exception: ',  $e->getMessage(), $ppName"\n";
        }

        try {
            
    $pres->SaveAs($strPath."\\".$FileName,17);  //'*** 18=PNG, 19=BMP **'
        
    } catch (Exception $e) {
            echo 
    'Caught exception: ',  $e->getMessage(), "\n"
        }

    }

    $ppApp->Quit;
    $ppApp null
    Additional configs added to the server are:
    DCOM config

    Component Services->Computers->My Computer->DCOM config-> Microsoft PowerPoint Presentation

    • Launch Permission - IUSR added with Local Activation permission
    • Launch Permission - NETWORK SERVICES added with Local Activation permission
    • Local Activation - IUSR added with Local Activation permission
    • Local Activation - NETWORK SERVICES added with Local Activation permission


    php.ini
    • com.allow_dcom = true


    folder permissions that contain ppt files

    • IUSR added with full control
    • Everybody added with full control (makes no different)
    • NETWORK SERVICES added with full control (makes no different)


    Further notes:
    Its worth mentioning that I have noticed a huge processor usage increase when upgrading from msoffice 2003 -> 2007

  2. #2
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,629
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    What is the app pool running as? I'd try a named user vs APP POOL IDENITITY.

    Actually, I wouldn't try and do this at all, especially with PHP. But if I had to do it I'd avoid APP POOL IDENTITY.

  3. #3
    SitePoint Enthusiast gazman99's Avatar
    Join Date
    May 2007
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for you response but I have tried that.... at least I think correctly.
    iis/application pools/ sitename / set application pool defaults; (is this correct?)

    the following user settings produce these responses:

    NetworkService, LocalSystem , Administrator
    Caught exception: Source: Microsoft Office PowerPoint 2007 Description: PowerPoint could not open the file

    LocalService, ApplicationPoolIdentity, #myOwnUser
    Caught exception: Failed to create COM object `powerpoint.application': Access is denied

    I really only have basic understandings of win2008 server management, so really am appreciative anymore ideas.
    G

  4. #4
    SitePoint Enthusiast gazman99's Avatar
    Join Date
    May 2007
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PROBLEM SOLVED!

    This was a bit of an odd one but just as we were about to abandon it, we found the solution on a developer forum (http://social.msdn.microsoft.com/For...6-44421818ef91)
    Basically a windows 2003 has a C:\Windows\System32\config\systemprofile\Desktop folder as default whereas on a windows 2008 this has been removed as default.
    I created this file and all works.... i can manipulate ppt and pptx files server side. (although Microsoft dont approve of msoffice automation)

    Thanks Mr H Ogawa

    Additional to this I created a new user (ppt_access) and added this to the DCOM config, folder permissions & application pool


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •