Maintain Formating of HTML Merged Data Source

K

Kristin MCKechie

Hi,

I am having trouble getting merged data out of an HTML
table to retain its preset formatting once merged (Using
Office 2000). I need to use HTML as the souce since I am
extracting the data from a live remote database for
multiple concurrent users via an .hta interface, also
since some of the fields are large memos the HTML table
seeems to be most easily merged.

I have tried the various combinations of {fieldname},
{MERGEFIELD fieldname \* MERGEFORMAT} and {REF fieldname}
to no avail.

The {fieldname} variant works best, but for some reason
the first paragraph of each fieled keeps getting
reformatted to centered/bolded, (but all the rest of the
fomatting - fonts, underlines, colors etc. are fine). If
I try the {REF fieldname} variant, I end up getting the
first few words of the first paragraph in each merge field
bolded by the bold formatting of the 'Error! Bookmark not
defined.' message...

I hope someone can help.
Kristin McKechie
Information Manager
Opus International Consultants (PCA) Ltd
Phone: (08) 9842 6155 Fax: (08) 9842 6055
Mobile: 04399 65747
EMail: (e-mail address removed)
 
P

Peter Jamieson

Unfortunately I suspect you will have real difficulty getting this to work
withut resorting to some VBA and postprocessing, since the {REF}/{fieldname}
approach is an undocumented trick that can't really be relied on as you have
discovered, and there is no other simple way to get formatted text from a
data source in a merge.

The only fairly obvious things I can think of are
a. there could be a paragraph style clash between the HTML file and your
mail merge main document.
b. the first paragraph could be more affected by the formatting of the
paragraph containing the {fieldname} field than the other paragraphs

I think in your situation I would consider one of the following
a. doing the merge to an output document then using Find/Replace and/or VBA
to fix the formatting (if it is always clear what it needs to be, and you
can easily locate the texts to be fixed)
b. convert the HTML to a .doc before merging and see if that makes any
difference
c. seeing if I could extract and re-use the correct formatted text directly
from the HTML using Word VBA, then perhaps "roll my own" merge code to do
the job.

Best I can do, sorry!
 
G

Guest

Hi Peter.

Believe it or not, your response has helped me to solve
this issue...

Using your idea of converting the html to .doc format, I
found that the merge would run fine using the {fieldname}
approach. I then resaved the new .doc source file back to
html using Word and tried again... and again the file
merged successfully...

I have now rebuilt my PHP script to generate an output
file from the web which exactly matches the html file
format (including the xml header block) created by Word
and all is sweet... A little bit round about, but at the
end of the day, I'm happy with whatever works...

Cheers
Kris M.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top