Author Topic: starting a ms-word template via php  (Read 1637 times)

0 Members and 1 Guest are viewing this topic.

Offline bm4499Topic starter

  • Irregular
  • Posts: 32
    • View Profile
starting a ms-word template via php
« on: March 16, 2010, 08:57:24 AM »
Does anyone know how to start a ms-word template via php?

Offline FD_F

  • Enthusiast
  • Posts: 61
  • Gender: Male
    • View Profile
Re: starting a ms-word template via php
« Reply #1 on: March 16, 2010, 11:44:11 AM »
you can open only in server side using

shell_exec("C:\Word Folder\winword.exe /ttemplate name");

more info:
http://support.microsoft.com/kb/290961

Offline bm4499Topic starter

  • Irregular
  • Posts: 32
    • View Profile
Re: starting a ms-word template via php
« Reply #2 on: March 17, 2010, 02:56:18 AM »
you can open only in server side using

shell_exec("C:\Word Folder\winword.exe /ttemplate name");

more info:
http://support.microsoft.com/kb/290961

So when we have intranet and we want to let users start templates via Intranet and MS-Word, it should not be possible to run the template onto visitors their local computer?

Offline thorpe

  • Administrator
  • 'Mind Boggling!'
  • *
  • Posts: 29,255
    • View Profile
Re: starting a ms-word template via php
« Reply #3 on: March 17, 2010, 04:01:19 AM »
PHP executes on the server so no. Not unless you open a local directory on the server itself.

Offline bm4499Topic starter

  • Irregular
  • Posts: 32
    • View Profile
Re: starting a ms-word template via php
« Reply #4 on: March 17, 2010, 04:53:16 AM »
PHP executes on the server so no. Not unless you open a local directory on the server itself.

Hmm, I see, how about another way to reach our target? Java?

Offline thorpe

  • Administrator
  • 'Mind Boggling!'
  • *
  • Posts: 29,255
    • View Profile
Re: starting a ms-word template via php
« Reply #5 on: March 17, 2010, 04:59:44 AM »
All server-side languages will have the same issue.

Offline bm4499Topic starter

  • Irregular
  • Posts: 32
    • View Profile
Re: starting a ms-word template via php
« Reply #6 on: March 17, 2010, 05:21:06 AM »
All server-side languages will have the same issue.

Hmm, thanks for your answer. Then we have to find another solution.

Offline thorpe

  • Administrator
  • 'Mind Boggling!'
  • *
  • Posts: 29,255
    • View Profile
Re: starting a ms-word template via php
« Reply #7 on: March 17, 2010, 05:45:00 AM »
I have no idea what an ms-word template actually is, but you could create it on the server and then have your users download it.

Or, you could (like I mentioned) try opening the template on a remotely accessed drive. Given the correct permissions, I can open remote drives from my windows machine at work quite easily.

Code: [Select]
\\machinename\c$

Will give me access to the C drive of the pc called machinename for instance.

Offline bm4499Topic starter

  • Irregular
  • Posts: 32
    • View Profile
Re: starting a ms-word template via php
« Reply #8 on: March 17, 2010, 06:10:28 AM »
I have no idea what an ms-word template actually is, but you could create it on the server and then have your users download it.

Or, you could (like I mentioned) try opening the template on a remotely accessed drive. Given the correct permissions, I can open remote drives from my windows machine at work quite easily.

Code: [Select]
\\machinename\c$

Will give me access to the C drive of the pc called machinename for instance.

a template is a written word doc with some wizzards that the use has to fill. The internal VBA software is taking care for things like house style, layout and other automated information.

You're right, the best way to do this all is at the server-side, but there is a big BUT:

Our current templates (many!) are based and adjusted for usage on their local machines, it looks up e.g. username, file counter and other stuff like that. Copying this stuff to server-side is not an easy option for us.

It's so strange, Windows-update and many online virusscanners are able to access your computer as well but we cannot...

Offline thorpe

  • Administrator
  • 'Mind Boggling!'
  • *
  • Posts: 29,255
    • View Profile
Re: starting a ms-word template via php
« Reply #9 on: March 17, 2010, 06:53:22 AM »
Quote
It's so strange, Windows-update and many online virusscanners are able to access your computer as well but we cannot...

Windows updates use an ActiveX control I believe, you could also maybe achieve what you want with a Java applet. Either way, this board is for help with existing third party code.

Offline bm4499Topic starter

  • Irregular
  • Posts: 32
    • View Profile
Re: starting a ms-word template via php
« Reply #10 on: March 18, 2010, 06:42:49 AM »
Quote
It's so strange, Windows-update and many online virusscanners are able to access your computer as well but we cannot...

Windows updates use an ActiveX control I believe, you could also maybe achieve what you want with a Java applet. Either way, this board is for help with existing third party code.

I've found another way to reach my target:

I made a sharedir at my local windows machine and with an executable I am looking each 1,5 second (via a timer) if there is a textfile in this directory which consist the right msword (*.dot) or msexcel (*.xlt) and start this template... This is tested successfully.

Now I have a problem that I cannot write the textfile into \\ipaddress\templatehelp\......

even creating the file to the root of the server c:\ and copying it to \\ipaddress\templatehelp\*  is not working... :-( What's wrong with this?


Offline thorpe

  • Administrator
  • 'Mind Boggling!'
  • *
  • Posts: 29,255
    • View Profile
Re: starting a ms-word template via php
« Reply #11 on: March 18, 2010, 07:04:17 AM »
Sounds like a permissions issue. Nothing to do with php.

Offline bm4499Topic starter

  • Irregular
  • Posts: 32
    • View Profile
Re: starting a ms-word template via php
« Reply #12 on: March 18, 2010, 07:11:19 AM »
Sounds like a permissions issue. Nothing to do with php.

I see, thanks for the advice, then I can continue seek to find the 'why' :-)

Offline bm4499Topic starter

  • Irregular
  • Posts: 32
    • View Profile
Re: starting a ms-word template via php
« Reply #13 on: March 18, 2010, 09:01:27 AM »
Sounds like a permissions issue. Nothing to do with php.

I see, thanks for the advice, then I can continue seek to find the 'why' :-)


$datatowrite = 'tmpl.dot';
 $fhdl = fopen('\\\\10.0.0.7\\App\\test.txt', 'w') or die("can't open file");
 fwrite($fhdl,$datatowrite);
 fclose($fhdl);

Why is this code not working?
When I use this line the file successfully is created:
 $fhdl = fopen('C:\\test.txt', 'w') or die("can't open file");


note: 10.0.0.7 is not the webserver but just a workstation on the same router as the webserver
« Last Edit: March 18, 2010, 09:09:04 AM by bm4499 »