?
Solved

How to strip word docx from 'template-fields' after mailmerge?

Posted on 2016-08-25
3
Medium Priority
?
148 Views
Last Modified: 2016-08-26
We have a PHP mailmerge app that unzips docx, substitutes mailmerge fields and zips them back, it all works fine and looks ok when opening. But if i try to print this 'new' document, all fields that were filled after opening, now have error messages in them. To resolve, we have to do ctl-a (select all) and shift-f9 in word and now all data is included and we can print the document.

I am looking for an alternative solution to the ctl-a shift-f9 in word, we are talking about hundreds of documents and although we have a macro solution we are looking at, we'd rather fix this at the php level when mailmerge is still going on.
How could we do this, fe. using the dom-structure of php, maybe disconnecting the fields from the value or something like it.
285_421_2_1_20160816_example.docx
0
Comment
Question by:zebrain777
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 41770463
The MailMerge process creates one or more documents from the  Main document but puts the values from the data record where the merge field is on the main document.

The main document does not get modified in the process. There are no merge fields in the output document(s).

Your document does not contain merge fields. The fields are REF fields, which are intended to show the contents of  bookmarks elsewhere on the document. There do not seem to be any bookmarks in your document.

I don't speak PHP, but there is a Fields.Unlink method that can be used programatically.
0
 
LVL 15

Expert Comment

by:DrTribos
ID: 41770926
Um.... why not just use the PHP to operate on a temporary copy of the document instead of unzipping the original, OR create a backup of the doc and use the PHP TO restore...?
0
 

Author Comment

by:zebrain777
ID: 41771705
Hmm not sure what happened with my previous comment, so i will try again:)

@GrahamSkan, ty i am now looking at SimpleXml for php wich seems capable of doing that. My problem is that xml is not my usual cup of tea i guess but the unlink comment may get me where i need to be, so i will accept your solution.

@DrTribos, yes there is a copy made of the original template, that one is processed, and is the one attached to the questiong, just manually manipulated for privacy reasons.
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question