Jump to content

how to call macro from php?


adrivetest

Recommended Posts

No matter what I tried to call my open office macro, whether it's exec, shell_exec, system or even COM("WScript.Shell"), the command line seems to be ignored without returning any errors from php. Sometimes it just hangs!

 

It's running fine from command line itself. (im using php 5.2.6, winxp, apache)

 

1. my php calls the following batch file through this :

 

$cmd = "c:\\php\\cmd.exe /c c:\\convert.cmd c:\myoutput.html";
$output = shell_exec($cmd);

 

2. convert.cmd contains the following to convert html into word:

 

@ECHO OFF

"C:\\Program Files\\OpenOffice.org 3\\program\\soffice" -invisible -headless "macro:///Standard.Conversion.ConvertHTMLToWord(%1)"

echo "Converted!"

EXIT

 

3. expected output on c:\ should have generated *.doc files but theres none. but i get a "Converted!" string back from $output. It seems to have ignored my macro call?

 

This doesn't happen if i call it directly through command prompt Or if i call it not through a web server such as :

 

<?php  

   $filename = $argv[1];
   
   $cmd = "c:\php\cmd.exe /c c:\convert.cmd $filename\n";

   echo $cmd;
   $output = shell_exec($cmd);
   
   print($output);
?>

 

then run with "C:\php\php c:\myoutput.html" it'll generate the doc file as well as "Converted!" string.

 

 

But what i really need is the ability to run it from apache hosted web server, through a web browser. How can i go about?

Link to comment
https://forums.phpfreaks.com/topic/133267-how-to-call-macro-from-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.