Ik kan vanuit php via com een word document openen deze wijzigen en weer netjes opslaan, geweldig! Maar nu wil ik simpelweg een woordje "TESTEN" vervangen voor "BLAAT" en dit krijg ik niet aan de praat. Op internet zijn er geen werkende voorbeelden te vinden.
Mijn code:
Het lijkt allemaal heel mooi, maar er wordt niets vervangen. Het openen en opslaan gaat echter wel goed.
Weet iemand de oplossing?
Mijn code:
code:
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
| <?php #Instantiate the Word component. $word = new COM("word.application") or die("Unable to instantiate Word"); #Get and print its version print "Loaded Word, version {$word->Version}<BR>"; #Another way to get the version using com_get $testversion = com_get($word->application,version); print "Version using Com_get(): $testversion <BR>"; #Make it visible in a window $word->Visible = 1; #Open a Word document $word->Documents->Open("d:/testje.doc"); $word->Selection->Find->ClearFormatting; $word->Selection->Find->Replacement->ClearFormatting; $word->Selection->Find->Text = "TESTEN"; $word->Selection->Find->Replacement->Text = "BLAAT"; $word->Selection->Find->Forward = True; $word->Selection->Find->Wrap = wdFindContinue; $word->Selection->Find->Format = False; $word->Selection->Find->MatchCase = False; $word->Selection->Find->MatchWholeWord = False; $word->Selection->Find->MatchWildcards = False; $word->Selection->Find->MatchSoundsLike = False; $word->Selection->Find->MatchWordForms = False; $word->Selection->Find->Execute(); #Now save the document $word->Documents[1]->SaveAs("d:/testje2.doc"); #Comment next line if you want to see the word document, #then close word manually $word->Quit(); #Comment if you want to see the word document, then close ?> |
Het lijkt allemaal heel mooi, maar er wordt niets vervangen. Het openen en opslaan gaat echter wel goed.
Weet iemand de oplossing?
AMD XP1800+, 512MB Intern, Maxtor 160Gig, Matrox G550 32 DDR Dual Head in een Chieftec DX-01-SLD