Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
HTML mailmerge templates
Message
From
28/11/2020 13:39:23
 
 
To
28/11/2020 12:25:12
Walter Meester
HoogkarspelNetherlands
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
01677316
Message ID:
01677321
Views:
66
>>>Hi All,
>>>
>>>I'm looking into the ability to create a mailmerge template (in the web browser control) and display when values are being filled in from a table. Just the way Word does it. I have been able to create a text editor from the IE web control (see attachment).
>>>I want to be able to create a button on the toolbar to insert a mailmerge field which is just a placeholder for the actual value after merging (just like in word).
>>>
>>>Moreover The HTML should preserve the mergefield so that the mergefields can update the values if they change.
>>>
>>>Has anyone have experience with this ?
>>
>>Walter,
>>
>>Can you insert a
>>
>><span id="fieldid" class="mergefield">Field name</span>
>>
>>in the document that the editor will not change? If so, you could pre- or post-process your document and fill in the fields according to their ids.
>
>Thanks antonio,
>
>Do you happen to have some VFP code to iterate throught the document to replace those values ?

A crude demo, Walter:
LOCAL HTMLSource AS String

TEXT TO m.HTMLSource NOSHOW FLAGS 1
<html>
 <head>
  <title>A document</title>
  <style>.field {color: red}</style>
 </head>
 <body>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
  dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
  commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat
  nulla pariatur. <span id="field001" class="field">Field #1</span> Excepteur sint occaecat cupidatat non
  proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
 </body>
</html>
ENDTEXT

STRTOFILE(m.HTMLSource, "wm.html")

LOCAL Browser AS BrowserForm

m.Browser = CREATEOBJECT("BrowserForm")
m.Browser.Show()
WAIT WINDOW "Load the document..."
m.Browser.LoadDocument(FULLPATH("wm.html"))
WAIT WINDOW "Set the field value..."
m.Browser.ProcessField("field001", "Walter")
WAIT WINDOW "Done!"

DEFINE CLASS BrowserForm AS Form

	ADD OBJECT HtmlViewer AS OleControl WITH Width = This.Width, Height = This.Height, OleClass = "Shell.Explorer"

	PROCEDURE Init
		This.HtmlViewer.Navigate2("about:blank")
	ENDPROC

	PROCEDURE LoadDocument (Document AS String)
		This.HtmlViewer.Navigate2(m.Document)
	ENDPROC

	PROCEDURE ProcessField (FieldId AS String, FieldValue AS String)
		This.HtmlViewer.Document.getElementById(m.FieldId).innerText = m.FieldValue
	ENDPROC

ENDDEFINE
----------------------------------
António Tavares Lopes
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform