tekst samenvoegen met word document php

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Creator90

creator90

08/02/2006 11:36:00
Quote Anchor link
Ik ben bezig om een word sjabloon te vullen met
waarden die ik in php invul.

nu heb ik de volgende code

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
error_reporting (0);
   // msword.inc.php
  
   // NOTE: Using COM with windows NT/2000/XP with apache as a service
   // - Run dcomcnfg.exe
   // - Find word application and click properties
   // - Click the Security tab
   // - Use Custom Access Permissions
   //      - Add the user who runs the web server service
   // - Use Custom Launch permissions
   //      - Add the user who runs the web server service

  
   $wdFormatDocument = 0;
   $wdFormatTemplate = 1;
   $wdFormatText = 2;
   $wdFormatTextLineBreaks = 3;
   $wdFormatDOSText = 4;
   $wdFormatDOSTextLineBreaks = 5;
   $wdFormatRTF = 6;
   $wdFormatUnicodeText = 7;
   $wdFormatHTML=8;

   class MSWord
   {
       // Vars:
       var $handle;
      
       // Create COM instance to word
       function MSWord($Visible = true)
       {

           $this->handle = new COM("word.application") or die("Unable to instanciate Word");
           $this->handle->Visible = $Visible;
       }

      
       // Open existing document
       function Open($File)
       {

           $this->handle->Documents->Open($File);
       }

      
       // Create new document
       function NewDocument()
       {

           $this->handle->Documents->Add();
       }

      
       // Write text to active document
       function WriteText( $Text )
       {

           $this->handle->Selection->Typetext( $Text );
       }

      
       // Number of documents open
       function DocumentCount()
       {

           return $this->handle->Documents->Count;
       }

      
       // Save document as another file and/or format
       function SaveAs($File, $Format = 0 )
       {

           $this->handle->ActiveDocument->SaveAs($File, $Format);
       }

      
       // Save active document
       function Save()
       {

           $this->handle->ActiveDocument->Save();
       }

      
       // close active document.
       function Close()
       {

           $this->handle->ActiveDocument->Close();
       }

      
       // Get word version
       function GetVersion()
       {

           return $this->handle->Version;
       }

      
       // get handle to word
       function GetHandle()
       {

           return $this->handle;
       }

  
       // Clean up instance with word
       function Quit()
       {

           if( $this->handle )
           {

               // close word
               $this->handle->Quit();
  
               // free the object
               $this->handle->Release();
               $this->handle = null;
           }
       }
   };


?>


Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
<?php
   $input
= "C:\\naam.doc";

   $Word = new MSWord;
    $Word->Open($input);
?>


Word wordt netjes geopend en nu wil ik een
docvariable vullen met een waarde uit een invoerveld. De docvarialbe in mijn word sjabloon heet DOCVARIABLE {"test"}

ik heb al van alles geprobeerd. een vb is:

$this->handle->ActiveDocument->Variables->Item("test")->Selection->Typetext( "jan" ); Iemand een idee hoe je dit moet doen.
 
PHP hulp

PHP hulp

15/05/2024 13:45:14
 
Elwin - Fratsloos

Elwin - Fratsloos

08/02/2006 11:56:00
Quote Anchor link
Hmm.. waar heb je de class vandaan? Staat daar geen readme?

Elwin
 
Creator90

creator90

08/02/2006 16:08:00
Quote Anchor link
Komt van www.php.net gezocht op COM

Geen verdere info hoe je een DOCVARIABLE in kan vullen

Ik heb heel internet al afgezocht en nog niets over gevonden.
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.